Search in sources :

Example 1 with Tank

use of buildcraft.lib.fluids.Tank in project BuildCraft by BuildCraft.

the class BuildingSlotMapIterator method refresh.

public void refresh(TileAbstractBuilder builder) {
    if (!isCreative) {
        availablePairs.clear();
        availablePairs.add(new BuilderItemMetaPair(null));
        if (builder != null) {
            for (int i = 0; i < builder.getSizeInventory(); i++) {
                ItemStack stack = builder.getStackInSlot(i);
                if (stack != null) {
                    availablePairs.add(new BuilderItemMetaPair(stack));
                }
            }
            for (Tank t : builder.getFluidTanks()) {
                if (t.getFluid() != null && t.getFluid().getFluid().getBlock() != null) {
                    availablePairs.add(new BuilderItemMetaPair(new ItemStack(t.getFluid().getFluid().getBlock())));
                }
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) Tank(buildcraft.lib.fluids.Tank) BuilderItemMetaPair(buildcraft.core.builders.BuilderItemMetaPair)

Example 2 with Tank

use of buildcraft.lib.fluids.Tank in project BuildCraft by BuildCraft.

the class GuiBuilder method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    // We cannot do super here due to some crazy shenanigans with a dynamically
    // resized GUI.
    GlStateManager.color(1f, 1f, 1f, 1f);
    boolean isBlueprint = builder.getStackInSlot(0) != null;
    mc.renderEngine.bindTexture(REGULAR_TEXTURE);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, ySize);
    mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
    if (isBlueprint) {
        drawTexturedModalRect(guiLeft + 169, guiTop, 169, 0, 256 - 169, ySize);
    }
    List<RequirementItemStack> needs = builder.getNeededItems();
    if (needs != null) {
        if (needs.size() > slots.size()) {
            getContainerBuilder().scrollbarWidget.hidden = false;
            getContainerBuilder().scrollbarWidget.setLength((needs.size() - slots.size() + 3) / 4);
        } else {
            getContainerBuilder().scrollbarWidget.hidden = true;
        }
        int offset = getContainerBuilder().scrollbarWidget.getPosition() * 4;
        for (int s = 0; s < slots.size(); s++) {
            int ts = offset + s;
            if (ts >= needs.size()) {
                ((SlotBuilderRequirement) slots.get(s)).stack = null;
            } else {
                ((SlotBuilderRequirement) slots.get(s)).stack = needs.get(ts);
            }
        }
        for (GuiButton b : (List<GuiButton>) buttonList) {
            b.visible = true;
        }
    } else {
        getContainerBuilder().scrollbarWidget.hidden = true;
        for (AdvancedSlot slot : slots) {
            ((SlotBuilderRequirement) slot).stack = null;
        }
        for (GuiButton b : (List<GuiButton>) buttonList) {
            b.visible = false;
        }
    }
    if (builder.getControlMode() == Mode.Off) {
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        int extraX = guiLeft + OPTION_EXTRA_X_POS.getAsInt();
        int extraY = guiTop + OPTION_EXTRA_Y_POS.getAsInt();
        drawTexturedModalRect(extraX, extraY, CoreIconProvider.TURNED_OFF.getSprite(), 16, 16);
    }
    drawWidgets(x, y);
    if (isBlueprint) {
        drawBackgroundSlots(x, y);
        for (int i = 0; i < builder.fluidTanks.length; i++) {
            Tank tank = builder.fluidTanks[i];
            if (tank.getFluid() != null && tank.getFluid().amount > 0) {
                drawFluid(tank.getFluid(), guiLeft + 179 + 18 * i, guiTop + 145, 16, 47, tank.getCapacity());
            }
        }
        mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
        for (int i = 0; i < builder.fluidTanks.length; i++) {
            Tank tank = builder.fluidTanks[i];
            if (tank.getFluid() != null && tank.getFluid().amount > 0) {
                drawTexturedModalRect(guiLeft + 179 + 18 * i, guiTop + 145, 0, 54, 16, 47);
            }
        }
    }
    GlStateManager.color(1f, 1f, 1f, 1f);
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) RequirementItemStack(buildcraft.core.blueprints.RequirementItemStack) ArrayList(java.util.ArrayList) List(java.util.List) Tank(buildcraft.lib.fluids.Tank)

Example 3 with Tank

use of buildcraft.lib.fluids.Tank in project BuildCraft by BuildCraft.

the class GuiBuilder method drawTooltips.

private void drawTooltips(int par1, int par2) {
    int top = guiTop + 145;
    for (int i = 0; i < builder.fluidTanks.length; i++) {
        int left = guiLeft + 179 + 18 * i;
        if (par1 >= left && par2 >= top && par1 < (left + 16) && par2 < (left + 47)) {
            List<String> fluidTip = new ArrayList<>();
            Tank tank = builder.fluidTanks[i];
            if (tank.getFluid() != null && tank.getFluid().amount > 0) {
                fluidTip.add(tank.getFluid().getLocalizedName());
                if (!BuildCraftCore.hideFluidNumbers) {
                    fluidTip.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + tank.getFluid().amount + " mB");
                }
            } else {
                fluidTip.add(StatCollector.translateToLocal("gui.fluidtank.empty"));
            }
            drawHoveringText(fluidTip, par1 - guiLeft, par2 - guiTop, fontRendererObj);
            return;
        }
    }
    drawTooltipForSlotAt(par1, par2);
}
Also used : ArrayList(java.util.ArrayList) Tank(buildcraft.lib.fluids.Tank)

Example 4 with Tank

use of buildcraft.lib.fluids.Tank in project BuildCraft by BuildCraft.

the class TileHeatExchange method getDebugInfo.

@Override
public void getDebugInfo(List<String> left, List<String> right, EnumFacing side) {
    Tank[] tanks = { inCoolable, inHeatable, outCooled, outHeated };
    left.add("");
    left.add("Sleep = " + sleep);
    for (Tank t : tanks) {
        left.add(StringUtils.capitalize(t.getTankName()) + ":");
        left.add(" " + t.getFluidAmount() + "/" + t.getCapacity() + "mB");
        left.add(" " + (t.getFluid() == null ? "empty" : t.getFluidType().getLocalizedName(t.getFluid())));
    }
}
Also used : Tank(buildcraft.lib.fluids.Tank)

Example 5 with Tank

use of buildcraft.lib.fluids.Tank in project BuildCraft by BuildCraft.

the class TileBuilder method fill.

@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
    Fluid fluid = resource.getFluid();
    Tank emptyTank = null;
    for (Tank tank : fluidTanks) {
        Fluid type = tank.getFluidType();
        if (type == fluid) {
            int used = tank.fill(resource, doFill);
            if (used > 0 && doFill) {
                sendNetworkUpdate();
            }
            return used;
        } else if (emptyTank == null && tank.isEmpty()) {
            emptyTank = tank;
        }
    }
    if (emptyTank != null) {
        int used = emptyTank.fill(resource, doFill);
        if (used > 0 && doFill) {
            sendNetworkUpdate();
        }
        return used;
    }
    return 0;
}
Also used : Fluid(net.minecraftforge.fluids.Fluid) Tank(buildcraft.lib.fluids.Tank) Blueprint(buildcraft.core.blueprints.Blueprint) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint)

Aggregations

Tank (buildcraft.lib.fluids.Tank)6 ArrayList (java.util.ArrayList)2 Blueprint (buildcraft.core.blueprints.Blueprint)1 BptBuilderBlueprint (buildcraft.core.blueprints.BptBuilderBlueprint)1 RequirementItemStack (buildcraft.core.blueprints.RequirementItemStack)1 BuilderItemMetaPair (buildcraft.core.builders.BuilderItemMetaPair)1 AdvancedSlot (buildcraft.core.lib.gui.AdvancedSlot)1 List (java.util.List)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ItemStack (net.minecraft.item.ItemStack)1 Fluid (net.minecraftforge.fluids.Fluid)1