Search in sources :

Example 1 with FluidNetwork

use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.

the class TileEntityMethaneSynthesizer method produceOutput.

private boolean produceOutput(EnumFacing outputDirection) {
    int provide = this.getMethaneProvide();
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, outputDirection);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(AsteroidsModule.fluidMethaneGas, Math.min(gasRequested, provide)), true);
                this.liquidTank.drain(usedGas, true);
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 2 with FluidNetwork

use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.

the class TileEntityElectrolyzer method produceOxygen.

private boolean produceOxygen(EnumFacing outputDirection) {
    int provide = this.getOxygenProvide(outputDirection);
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).modifyPositionFromSide(outputDirection).getTileEntity(this.worldObj);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
                this.drawOxygen(usedGas, true);
                return true;
            }
        } else if (outputTile instanceof IOxygenReceiver) {
            float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
            if (requestedOxygen > 0) {
                int toSend = Math.min(this.getOxygenStored(), provide);
                int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), toSend, true);
                this.drawOxygen(acceptedOxygen, true);
                return true;
            }
        }
    // else if (EnergyConfigHandler.isMekanismLoaded())
    // {
    // //TODO Oxygen item handling - internal tank (IGasItem)
    // //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
    // //this.drawOxygen(acceptedOxygen, true);
    // 
    // if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
    // {
    // GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(Math.min(this.getOxygenStored(), provide)));
    // int acceptedOxygen = 0;
    // try {
    // acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
    // } catch (Exception e) { }
    // this.drawOxygen(acceptedOxygen, true);
    // return true;
    // }
    // }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) IOxygenReceiver(micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 3 with FluidNetwork

use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.

the class GCNEIHighlightHandler method handleTextData.

@Override
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, ItemInfo.Layout layout) {
    if (stack != null) {
        if (stack.getItem() == Item.getItemFromBlock(GCBlocks.fluidTank)) {
            if (layout == ItemInfo.Layout.BODY) {
                TileEntity tile = world.getTileEntity(mop.getBlockPos());
                if (tile instanceof TileEntityFluidTank) {
                    TileEntityFluidTank tank = (TileEntityFluidTank) tile;
                    FluidTankInfo[] infos = tank.getTankInfo(EnumFacing.DOWN);
                    if (infos.length == 1) {
                        FluidTankInfo info = infos[0];
                        currenttip.add(info.fluid != null ? info.fluid.getLocalizedName() : "Empty");
                        currenttip.add((info.fluid != null ? info.fluid.amount : 0) + " / " + info.capacity);
                    }
                }
            }
        } else if (stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipe) || stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipePull)) {
            if (layout == ItemInfo.Layout.BODY) {
                TileEntity tile = world.getTileEntity(mop.getBlockPos());
                if (tile instanceof TileEntityFluidPipe) {
                    TileEntityFluidPipe pipe = (TileEntityFluidPipe) tile;
                    currenttip.add(((BlockFluidPipe) pipe.getBlockType()).getMode().toString());
                    if (pipe.hasNetwork()) {
                        FluidNetwork network = ((FluidNetwork) pipe.getNetwork());
                        currenttip.add("Network: " + (network.buffer != null ? network.buffer.amount : 0) + " / " + network.getCapacity());
                    } else {
                        currenttip.add("Pipe: " + (pipe.getBuffer() != null ? pipe.getBuffer().amount + " / " + pipe.buffer.getCapacity() : "None"));
                    }
                }
            }
        }
    }
    return currenttip;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) TileEntityFluidTank(micdoodle8.mods.galacticraft.core.tile.TileEntityFluidTank) TileEntityFluidPipe(micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe)

Example 4 with FluidNetwork

use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.

the class TileEntityFluidPipeRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityFluidPipe pipe, double x, double y, double z, float partialTicks, int destroyStage) {
    updateModels();
    if (pipe.getBlockType() == GCBlocks.oxygenPipePull) {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) x, (float) y, (float) z);
        RenderHelper.disableStandardItemLighting();
        this.bindTexture(TextureMap.locationBlocksTexture);
        if (Minecraft.isAmbientOcclusionEnabled()) {
            GlStateManager.shadeModel(GL11.GL_SMOOTH);
        } else {
            GlStateManager.shadeModel(GL11.GL_FLAT);
        }
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        TileEntity[] adj = OxygenUtil.getAdjacentFluidConnections(pipe);
        for (EnumFacing facing : EnumFacing.VALUES) {
            TileEntity sideTile = adj[facing.ordinal()];
            if (sideTile != null && !(sideTile instanceof IBufferTransmitter)) {
                GL11.glPushMatrix();
                if (sideTile instanceof TileEntityFluidTank)
                    switch(facing) {
                        case SOUTH:
                            GL11.glTranslatef(0F, 0F, 1 / 16F);
                            break;
                        case NORTH:
                            GL11.glTranslatef(0F, 0F, -1 / 16F);
                            break;
                        case EAST:
                            GL11.glTranslatef(1 / 16F, 0F, 0F);
                            break;
                        case WEST:
                            GL11.glTranslatef(-1 / 16F, 0F, 0F);
                            break;
                    }
                ClientUtil.drawBakedModel(pullConnectorModel[facing.ordinal()]);
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
    }
    float scale;
    if (pipe.hasNetwork()) {
        FluidNetwork network = (FluidNetwork) pipe.getNetwork();
        scale = network.fluidScale;
    } else {
        scale = pipe.buffer.getFluidAmount() / (float) pipe.buffer.getCapacity();
    }
    Fluid fluid;
    if (pipe.hasNetwork()) {
        FluidNetwork network = (FluidNetwork) pipe.getNetwork();
        fluid = network.refFluid;
    } else {
        fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid();
    }
    if (fluid == null) {
        return;
    }
    if (scale > 0.01) {
        this.bindTexture(TextureMap.locationBlocksTexture);
        GL11.glPushMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float opacity = 1.0F;
        boolean gas = fluid.isGaseous();
        if (gas) {
            opacity = scale;
        }
        GL11.glColor4f(1.0F, 1.0F, 1.0F, opacity);
        TileEntity[] connections = OxygenUtil.getAdjacentFluidConnections(pipe);
        for (EnumFacing side : EnumFacing.VALUES) {
            TileEntity sideTile = connections[side.ordinal()];
            if (sideTile != null) {
                Integer[] displayLists = getListAndRender(side, fluid);
                if (displayLists != null) {
                    if (!gas) {
                        Integer list = displayLists[Math.max(3, (int) (scale * (stages - 1)))];
                        GL11.glCallList(list);
                    } else {
                        Integer list = displayLists[stages - 1];
                        GL11.glCallList(list);
                    }
                }
            }
        }
        Integer[] displayLists = getListAndRender(null, fluid);
        if (displayLists != null) {
            if (!gas) {
                Integer list = displayLists[Math.max(3, (int) (scale * (stages - 1)))];
                GL11.glCallList(list);
            } else {
                Integer list = displayLists[stages - 1];
                GL11.glCallList(list);
            }
        }
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) EnumFacing(net.minecraft.util.EnumFacing) Fluid(net.minecraftforge.fluids.Fluid) IBufferTransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter) TileEntityFluidTank(micdoodle8.mods.galacticraft.core.tile.TileEntityFluidTank)

Example 5 with FluidNetwork

use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.

the class TileEntityOxygen method produceOxygen.

public boolean produceOxygen(EnumFacing outputDirection) {
    int provide = this.getOxygenProvide(outputDirection);
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, outputDirection);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
                this.drawOxygen(usedGas, true);
                return true;
            }
        } else if (outputTile instanceof IOxygenReceiver) {
            float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
            if (requestedOxygen > 0) {
                int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), provide, true);
                this.drawOxygen(acceptedOxygen, true);
                return true;
            }
        }
    // else if (EnergyConfigHandler.isMekanismLoaded())
    // {
    // //TODO Oxygen item handling - internal tank (IGasItem)
    // //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
    // //this.drawOxygen(acceptedOxygen, true);
    // 
    // if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
    // {
    // GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(provide));
    // int acceptedOxygen = 0;
    // try {
    // acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
    // } catch (Exception e) { }
    // this.drawOxygen(acceptedOxygen, true);
    // return true;
    // }
    // }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) FluidStack(net.minecraftforge.fluids.FluidStack) IOxygenReceiver(micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)13 TileEntity (net.minecraft.tileentity.TileEntity)10 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)8 IBufferTransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter)3 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)3 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)3 EntitySpaceshipBase (micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase)2 IOxygenReceiver (micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver)2 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)2 TileEntityFluidTank (micdoodle8.mods.galacticraft.core.tile.TileEntityFluidTank)2 ScheduledDimensionChange (micdoodle8.mods.galacticraft.core.wrappers.ScheduledDimensionChange)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 WorldServer (net.minecraft.world.WorldServer)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 GameProfile (com.mojang.authlib.GameProfile)1 MinecraftProfileTexture (com.mojang.authlib.minecraft.MinecraftProfileTexture)1 Type (com.mojang.authlib.minecraft.MinecraftProfileTexture.Type)1 Property (com.mojang.authlib.properties.Property)1