Package mods.railcraft.common.fluids.tanks

Examples of mods.railcraft.common.fluids.tanks.StandardTank


        if (tile instanceof TileTankIronValve) {
            TileTankIronValve valve = (TileTankIronValve) tile;

            if (valve.isFilling()) {
                StandardTank tank = valve.getFillTank();
                FluidStack fluidStack = tank.getFluid();
                if (fluidStack != null && fluidStack.amount > 0 && fluidStack.getFluid() != null) {
                    GL11.glPushMatrix();
                    if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY() - 1, valve.getPatternPositionZ()) == 'A') {

                        prepFillTexture(fluidStack);

                        int height = getTankHeight(valve);
                        float yOffset = height / 2f;
                        float vScale = height - 2f;
                        GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset - height + 1, (float) z + 0.5F);
                        GL11.glScalef(1f, vScale, 1f);

                        draw(tank);
                    } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX() - 1, valve.getPatternPositionY(), valve.getPatternPositionZ()) == 'A') {

                        prepFillTexture(fluidStack);

                        float vScale = getVerticalScaleSide(valve);
                        float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                        GL11.glTranslatef((float) x - 0.5F + RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
                        GL11.glScalef(1f, vScale, 1f);

                        draw(tank);
                    } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX() + 1, valve.getPatternPositionY(), valve.getPatternPositionZ()) == 'A') {

                        prepFillTexture(fluidStack);

                        float vScale = getVerticalScaleSide(valve);
                        float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                        GL11.glTranslatef((float) x + 1.5F - RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
                        GL11.glScalef(1f, vScale, 1f);

                        draw(tank);
                    } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY(), valve.getPatternPositionZ() - 1) == 'A') {

                        prepFillTexture(fluidStack);

                        float vScale = getVerticalScaleSide(valve);
                        float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                        GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z - 0.5F + RenderTools.PIXEL * 5);
                        GL11.glScalef(1f, vScale, 1f);

                        draw(tank);
                    } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY(), valve.getPatternPositionZ() + 1) == 'A') {

                        prepFillTexture(fluidStack);

                        float vScale = getVerticalScaleSide(valve);
                        float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                        GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z + 1.5F - RenderTools.PIXEL * 5);
                        GL11.glScalef(1f, vScale, 1f);

                        draw(tank);
                    }
                    GL11.glPopMatrix();
                }
            }
        }

        TileTankBase ironTank = (TileTankBase) tile;
        if (!ironTank.isMaster() || ironTank.isInvalid())
            return;
        int height = getTankHeight(ironTank);
        float yOffset = height / 2f;
        float vScale = height - 2;
        float hScale = ironTank.getPattern().getPatternWidthX() - 2;

        TankManager tankManager = ironTank.getTankManager();
        if (tankManager == null)
            return;
        StandardTank tank = tankManager.get(0);
        if (tank == null)
            return;

        FluidStack fluidStack = tank.getFluid();
        if (fluidStack != null && fluidStack.amount > 0 && fluidStack.getFluid() != null) {
            preGL();
            GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset + 0.01f, (float) z + 0.5F);
            GL11.glScalef(hScale, vScale, hScale);

//        GL11.glScalef(0.999f, 1, 0.999f);
            int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack);
            if (displayLists != null) {
                GL11.glPushMatrix();

                float cap = tank.getCapacity();
                float level = (float) Math.min(fluidStack.amount, cap) / cap;

                bindTexture(FluidRenderer.getFluidSheet(fluidStack));
                FluidRenderer.setColorForTank(tank);
                GL11.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]);
View Full Code Here


    public void updateEntity() {
        super.updateEntity();
        if (Game.isHost(worldObj)) {
            TileBoilerFirebox mBlock = (TileBoilerFirebox) getMasterBlock();
            if (mBlock != null) {
                StandardTank tank = mBlock.tankManager.get(TANK_STEAM);
                FluidStack steam = tank.getFluid();
                if (steam != null && (!mBlock.boiler.isBoiling() || steam.amount >= tank.getCapacity() / 2))
                    mBlock.tankManager.outputLiquid(tileCache, getOutputFilter(), ForgeDirection.VALID_DIRECTIONS, TANK_STEAM, TRANSFER_RATE);
            }
        }
    }
View Full Code Here

    public ContainerTank(InventoryPlayer inventoryplayer, ITankTile tile) {
        super(tile.getInventory());
        this.tile = tile;

        StandardTank tank = tile.getTank();
        if (tank != null) {
            addWidget(new FluidGaugeWidget(tank, 35, 23, 176, 0, 48, 47));
        }

        addSlot(input = tile.getInputSlot(tile.getInventory(), 0, 116, 21));
View Full Code Here

            return null;
        return tanks.get(tankIndex);
    }

    public void setCapacity(int tankIndex, int capacity) {
        StandardTank tank = get(tankIndex);
        tank.setCapacity(capacity);
        FluidStack fluidStack = tank.getFluid();
        if (fluidStack != null && fluidStack.amount > capacity)
            fluidStack.amount = capacity;
    }
View Full Code Here

            TileTankIronValve valveBelow = null;
            if (tileBelow instanceof TileTankIronValve) {
                valveBelow = (TileTankIronValve) tileBelow;
                if (valveBelow.isStructureValid() && valveBelow.getPatternMarker() == 'T') {
                    StandardTank tankBelow = valveBelow.getTankManager().get(0);
                    FluidStack liquid = tankBelow.getFluid();
                    if (liquid != null && liquid.amount >= tankBelow.getCapacity() - FluidHelper.BUCKET_VOLUME) {
                        valveBelow = null;

                        FluidStack fillStack = liquid.copy();
                        fillStack.amount = FluidHelper.BUCKET_VOLUME - (tankBelow.getCapacity() - liquid.amount);
                        if (fillStack.amount > 0) {
                            int used = tank.fill(fillStack, false);
                            if (used > 0) {
                                fillStack = tankBelow.drain(used, true);
                                tank.fill(fillStack, true);
                            }
                        }
                    }
                } else
View Full Code Here

        patterns.add(new MultiBlockPattern(map, 2, 1, 2));
    }

    public TileCokeOven() {
        super("railcraft.gui.coke.oven", 4, patterns);
        tank = new StandardTank(TANK_CAPACITY, this);
        tankManager.add(tank);
    }
View Full Code Here

    }

    public void writeTanksToNBT(NBTTagCompound data) {
        NBTTagList tagList = new NBTTagList();
        for (byte slot = 0; slot < tanks.size(); slot++) {
            StandardTank tank = tanks.get(slot);
            if (tank.getFluid() != null) {
                NBTTagCompound tag = new NBTTagCompound();
                tag.setByte("tank", slot);
                tank.writeToNBT(tag);
                tagList.appendTag(tag);
            }
        }
        data.setTag("tanks", tagList);
    }
View Full Code Here

    }

    public void writePacketData(DataOutputStream data, int tankIndex) throws IOException {
        if (tankIndex >= tanks.size())
            return;
        StandardTank tank = tanks.get(tankIndex);
        FluidStack fluidStack = tank.getFluid();
        if (fluidStack != null) {
            data.writeShort(fluidStack.fluidID);
            data.writeInt(fluidStack.amount);
            data.writeInt(fluidStack.getFluid().getColor(fluidStack));
        } else
View Full Code Here

    }

    public void readPacketData(DataInputStream data, int tankIndex) throws IOException {
        if (tankIndex >= tanks.size())
            return;
        StandardTank tank = tanks.get(tankIndex);
        int fluidId = data.readShort();
        if (fluidId != -1) {
            tank.setFluid(new FluidStack(fluidId, data.readInt()));
            tank.colorCache = data.readInt();
        } else
            tank.setFluid(null);
    }
View Full Code Here

        player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
        PacketBuilder.instance().sendGuiIntegerPacket((EntityPlayerMP) player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
    }

    public void updateGuiData(Container container, List crafters, int tankIndex) {
        StandardTank tank = tanks.get(tankIndex);
        FluidStack fluidStack = tank.getFluid();
        FluidStack prev = prevFluidStacks.get(tankIndex);
        int color = tank.getColor();
        int pColor = prevColor.get(tankIndex);

        for (Object crafter1 : crafters) {
            ICrafting crafter = (ICrafting) crafter1;
            EntityPlayerMP player = (EntityPlayerMP) crafter1;
            if (fluidStack == null ^ prev == null) {
                int fluidId = -1;
                int fluidAmount = 0;
                if (fluidStack != null) {
                    fluidId = fluidStack.fluidID;
                    fluidAmount = fluidStack.amount;
                }
                crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
                PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
            } else if (fluidStack != null && prev != null) {
                if (fluidStack.getFluid() != prev.getFluid())
                    crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidStack.fluidID);
                if (fluidStack.amount != prev.amount)
                    PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
                if (color != pColor)
                    PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 2, color);
            }
        }

        prevFluidStacks.set(tankIndex, tank.getFluid() == null ? null : tank.getFluid().copy());
        prevColor.set(tankIndex, color);
    }
View Full Code Here

TOP

Related Classes of mods.railcraft.common.fluids.tanks.StandardTank

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.