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())));
}
}
}
}
}
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);
}
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);
}
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())));
}
}
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;
}
Aggregations