@Override public IFluidTankProperties[] getTankProperties() { if(hasParent()) { IFluidHandler iFluidHandler = parent.get(); assert iFluidHandler != null; IFluidTankProperties[] iFluidTankPropertiesArray = iFluidHandler.getTankProperties(); if(iFluidTankPropertiesArray.length > 0) { IFluidTankProperties fluidTankProperties = iFluidHandler.getTankProperties()[0]; return new IFluidTankProperties[]{new FluidTankProperties(fluidTankProperties.getContents(), fluidTankProperties.getCapacity(), true, false)}; } } return EmptyFluidHandler.EMPTY_TANK_PROPERTIES_ARRAY; }
@Override public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if(config.getConfig(WailaRegistrar.CONFIG_TANK)) { TileEntity te = accessor.getTileEntity(); if(te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) { IFluidHandler fluidHandler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); assert fluidHandler != null; IFluidTankProperties[] fluidHandlerTankProperties = fluidHandler.getTankProperties(); for(IFluidTankProperties fluidTankProperties : fluidHandlerTankProperties) { FluidStack fluidStack = fluidTankProperties.getContents(); if(fluidStack != null) { currenttip.add(Util.translateFormatted("gui.waila.tank.fluid", fluidStack.getLocalizedName())); currenttip.add(Util.translateFormatted("gui.waila.tank.amount", fluidStack.amount, fluidTankProperties.getCapacity())); } else { currenttip.add(Util.translate("gui.waila.tank.empty")); } } } } return currenttip; }
@Override public int getCapacity() { return internalTankProperties.getCapacity(); }
@Nonnull @Override public Map<Object, Object> getMeta(@Nonnull IFluidTankProperties tank) { return Collections.singletonMap("capacity", tank.getCapacity()); }
@Override public int getCapacity() { IFluidTankProperties[] props = getProperties(); if (props != null) { int cap = 0; for (IFluidTankProperties properties : props) { cap += properties.getCapacity(); } return cap; } return 0; }
private int getFreeSpaceInsideTank(IFluidTankProperties tanks) { if (tanks == null) { return 0; } FluidStack liquid = tanks.getContents(); if (liquid == null || liquid.getFluid() != null) { return tanks.getCapacity(); } if (FluidIdentifier.get(liquid).equals(this)) { return tanks.getCapacity() - liquid.amount; } return 0; } }
@Override public int getMaxLiquid(@Nonnull Inventory side) { IFluidHandler handler = getFluidHandlerAt(side); IFluidTankProperties[] properties = handler.getTankProperties(); if (properties != null && properties.length > 0) { return properties[0].getCapacity(); } return 0; }
public static int getCapacity(ItemStack itemStack) { if (itemStack == null) { return 0; } IFluidHandler handler = FluidUtil.getFluidHandler(itemStack); int amount = 0; if(handler != null){ for (IFluidTankProperties tank : handler.getTankProperties()) { amount += tank.getCapacity(); } } return amount; }
@Override public FluidTankInfo getFluidTankInfo() { return new FluidTankInfo(prop.getContents(), prop.getCapacity()); }
/** * Get the fluidstack capacity from the given itemstack. * @param itemStack The itemstack. * @return The capacity */ public static int getFluidStackCapacity(ItemStack itemStack) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(itemStack); if (fluidHandler != null) { for (IFluidTankProperties properties : fluidHandler.getTankProperties()) { return properties.getCapacity(); } } return 0; }
@Override public void drawButton( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ) { if( this.visible ) { GlStateManager.disableBlend(); GlStateManager.disableLighting(); drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 ); final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot ); if( fluid != null && fluid.getStackSize() > 0 ) { mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); float red = ( fluid.getFluid().getColor() >> 16 & 255 ) / 255.0F; float green = ( fluid.getFluid().getColor() >> 8 & 255 ) / 255.0F; float blue = ( fluid.getFluid().getColor() & 255 ) / 255.0F; GlStateManager.color( red, green, blue ); TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() ); final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) ); int iconHeightRemainder = scaledHeight % 16; if( iconHeightRemainder > 0 ) { this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder ); } for( int i = 0; i < scaledHeight / 16; i++ ) { this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 ); } } } }
@Override public ValueTypeInteger.ValueInteger get(int index) { return ValueTypeInteger.ValueInteger.of(getTank().getTankProperties()[index].getCapacity()); } }
@Override public int getCapacity() { int total = 0; for (IFluidHandler tank : getTanks()) { for (IFluidTankProperties info : tank.getTankProperties()) { total = Helpers.addSafe(total, info.getCapacity()); } } return total; }
public static boolean isFilled(ItemStack itemStack) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(itemStack); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { if (properties.getCapacity() > 0) { FluidStack contents = properties.getContents(); if (contents == null) { continue; } else if (contents.amount > 0) { return true; } } } return false; }
@Override public int comparatorInput() { IFluidTankProperties tank = getStorage().getTankProperties()[0]; FluidStack fluid = tank.getContents(); if (fluid == null) { fluid = FluidUtils.emptyFluid(); } return fluid.amount * 14 / tank.getCapacity() + (fluid.amount > 0 ? 1 : 0); }
public static boolean isDrainableFilledContainer(ItemStack container) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { if (!properties.canDrain()) { return false; } FluidStack contents = properties.getContents(); if (contents == null || contents.amount < properties.getCapacity()) { return false; } } return true; }
public static boolean isFillableContainerAndEmpty(ItemStack container) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { if (properties.canFill() && properties.getCapacity() > 0) { FluidStack contents = properties.getContents(); if (contents == null) { return true; } else if (contents.amount > 0) { return false; } } } return false; }
public static boolean isDrainableFilledContainer(ItemStack container) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { if (!properties.canDrain()) { return false; } FluidStack contents = properties.getContents(); if (contents == null || contents.amount < properties.getCapacity()) { return false; } } return true; }
public boolean render(@Nonnull ItemStack stack, int xPosition, int yPosition, int barOffset, boolean alwaysShow) { IFluidHandler cap = FluidUtil.getFluidHandlerCapability(stack); if (cap == null || cap.getTankProperties() == null || cap.getTankProperties().length <= 0) { return false; } IFluidTankProperties tank = cap.getTankProperties()[0]; if (tank == null || tank.getCapacity() <= 0) { return false; } int maxFluid = tank.getCapacity(); FluidStack fluidStack = tank.getContents(); int fluidAmount = fluidStack == null ? 0 : fluidStack.amount; if (alwaysShow || shouldShowBar(maxFluid, fluidAmount)) { double level = (double) fluidAmount / (double) maxFluid; boolean up = stack.getItem().showDurabilityBar(stack); boolean top = stack.getCount() != 1; render(level, xPosition, yPosition, top ? 12 - barOffset : up ? 2 + barOffset : barOffset, (barOffset & 1) == 0); return true; } return false; }
private boolean fillHandler() { IFluidHandlerItem handler = inventory[1].getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); int filled = tank.getFluid() == null ? 0 : handler.fill(new FluidStack(tank.getFluid(), Math.min(tank.getFluidAmount(), Fluid.BUCKET_VOLUME)), true); IFluidTankProperties[] tankProperties = handler.getTankProperties(); if (tankProperties == null || tankProperties.length < 1) { return true; } if (filled > 0) { tank.drain(filled, true); inventory[1] = handler.getContainer(); return tankProperties[0].getContents() != null && tankProperties[0].getContents().amount >= tankProperties[0].getCapacity(); } return true; }