IFluidTank tank = getTankAt(currentTank); assert tank != null; FluidStack tankFluid = tank.getFluid(); assert tankFluid != null; info.fluid = tankFluid.copy(); info.heat = temperature + 300; info.maxCap = tank.getCapacity(); if(tank != null && tank.getFluidAmount() > 0) { assert tank.getFluid() != null; info.fluid = tank.getFluid().copy(); info.heat = info.fluid.getFluid().getTemperature(info.fluid); info.maxCap = tank.getCapacity(); else if(tank.getFluid().isFluidEqual(info.fluid)) { info.fluid.amount += tank.getFluidAmount(); info.maxCap += tank.getCapacity();
IFluidTank tank = ((TileTank) te).getInternalTank(); FluidStack liquid = tank.getFluid(); if(liquid != null) { FluidStack in = liquid.copy(); int bonusFuel = TinkerRegistry.consumeSmelteryFuel(in); int amount = liquid.amount - in.amount; FluidStack drained = tank.drain(amount, false); tank.drain(amount, true); currentFuel = drained.copy(); fuelQuality = bonusFuel;
private int fillTanksImpl(FluidStack resource, boolean doFill) { int totalFilled = 0; //first, try to fill tanks that already have same fluid type for (IFluidTank handler : fluidTanks) { if(resource.isFluidEqual(handler.getFluid())) { int filledAmount = handler.fill(resource, doFill); totalFilled += filledAmount; resource.amount -= filledAmount; //if filling multiple tanks is not allowed, or resource is empty, return now if(!allowSameFluidFill || resource.amount == 0) return totalFilled; } } //otherwise, try to fill empty tanks for(IFluidTank handler : fluidTanks) { if(handler.getFluidAmount() == 0) { int filledAmount = handler.fill(resource, doFill); totalFilled += filledAmount; resource.amount -= filledAmount; if(!allowSameFluidFill || resource.amount == 0) return totalFilled; } } return totalFilled; }
private boolean hasTankWithFuel(BlockPos pos, FluidStack preference) { IFluidTank tank = getTankAt(pos); if(tank != null && tank.getFluid() != null) { if(tank.getFluidAmount() > 0 && TinkerRegistry.isSmelteryFuel(tank.getFluid())) { // if we have a preference, only use that if(preference != null && tank.getFluid().isFluidEqual(preference)) { return true; } else if(preference == null) { return true; } } } return false; }
public TankInfo(final IFluidTank tank) { this.capacity = 0.0f; this.capacity = tank.getCapacity(); this.liquid = tank.getFluid(); }
@Override public FluidStack get(int index) { return backedList.get(index).getFluid(); }
public boolean spaceInTank(final int id, final int amount) { final IFluidTank tank = this.getTank(id); final int space = tank.getCapacity() - tank.getFluidAmount(); return amount <= space; }
@Override protected long getEnergyCapacity() { return (long) Math.floor(steamFluidTank.getCapacity() * conversionRate); }
@Override protected long getEnergyStored() { return (long) Math.ceil(steamFluidTank.getFluidAmount() * conversionRate); }
@Override protected boolean drawEnergy(int recipeEUt) { int resultDraw = (int) Math.floor(recipeEUt / conversionRate); return resultDraw >= 0 && steamFluidTank.getFluidAmount() >= resultDraw && steamFluidTank.drain(resultDraw, true) != null; }
int liquidAmount = tank.getFluidAmount(); FluidStack fillAmount = ((FluidTank) tank).drainInternal(Fluid.BUCKET_VOLUME, true); int filled = fluidHandlerItem.fill(fillAmount, true); tank.drain(filled, true); player.inventory.setItemStack(fluidHandlerItem.getContainer()); player.updateHeldItem(); if (potential != null) { if (tank instanceof FluidTank) { int fill = tank.fill(potential, true); fluidHandlerItem.drain(fill, true); player.inventory.setItemStack(fluidHandlerItem.getContainer());
@Override public int fill(FluidStack resource, boolean doFill) { // this is where all the action happens if(resource == null || tileCasting.isStackInSlot(1)) { return 0; } Fluid fluid = resource.getFluid(); // if empty, find a new recipe if(this.tank.getFluidAmount() == 0) { int capacity = tileCasting.initNewCasting(fluid, doFill); if(capacity > 0) { // new tank with the wanted capacity so we can simulate fill with the correct capacity IFluidTank calcTank = new FluidTank(resource.getFluid(), 0, capacity); // no extra checks needed for the tank since it's empty and we have to set the capacity anyway if(doFill) { tank.setCapacity(capacity); tank.setFluid(new FluidStack(resource.getFluid(), 0)); calcTank = tank; } return calcTank.fill(resource, doFill); } } // non-empty tank. just try to fill return tank.fill(resource, doFill); }
public boolean liquidInTank(final int tankIndex, final int amount) { IFluidTank tank = this.getTank(tankIndex); FluidStack drain = tank.drain(amount, false); return drain != null && drain.amount == amount; }
public int getFreeSpaceInsideTank(IFluidTank tank) { FluidStack liquid = tank.getFluid(); if (liquid == null || liquid.getFluid() != null) { return tank.getCapacity(); } if (FluidIdentifier.get(liquid).equals(this)) { return tank.getCapacity() - liquid.amount; } return 0; }
@Nullable @Override public FluidStack convert(@Nonnull IFluidTank from) { return from.getFluid(); } }
@Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String s = I18n.format("container.drink_machine"); this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752); this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752); renderer.render(Minecraft.getMinecraft(), 26, 11, fluidTank.getFluid()); if (rectangle.contains(mouseX - guiLeft, mouseY - guiTop) && fluidTank.getFluidAmount() != 0) { ScaledResolution scaledresolution = new ScaledResolution(mc); GuiUtils.drawHoveringText(ItemStack.EMPTY, renderer.getTooltip(mc, fluidTank.getFluid(), ITooltipFlag.TooltipFlags.NORMAL), mouseX - guiLeft, mouseY - guiTop, scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), -1, fontRenderer); } }
protected int getScaled() { if (tank.getCapacity() < 0) { return sizeY; } long fraction = (long) tank.getFluidAmount() * sizeY / tank.getCapacity(); return alwaysShowMinimum && tank.getFluidAmount() > 0 ? Math.max(1, MathHelper.ceil(fraction)) : MathHelper.ceil(fraction); }
@Nonnull @Override public Map<Object, Object> getMeta(@Nonnull IFluidTank tank) { return Collections.singletonMap("capacity", tank.getCapacity()); }
@Override public int getFluidAmount() { IFluidTank tank = getTank(); if (tank == null) { return 0; } return tank.getFluidAmount(); }
public void fillTank(final int id, final FluidStack liquidStack) { final IFluidTank tank = this.getTank(id); tank.fill(liquidStack, true); }