@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; }
final FluidStack newFS = tankProperties[slot].getContents();
@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; }
high = Math.max( high, slot ); final FluidStack newIS = !props[slot].canDrain() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : props[slot].getContents(); final FluidStack oldIS = old == null ? null : old.fluidStack;
@Nullable @Override public FluidStack getContents() { return internalTankProperties.getContents(); }
@Nullable @Override public FluidStack convert(@Nonnull IFluidTankProperties from) { return from.getContents(); } }
private int countFluid(IFluidHandler handler, @Nullable FluidStack matcher) { int cnt = 0; for (IFluidTankProperties properties : handler.getTankProperties()) { if (properties.getContents() != null && (matcher == null || matcher.equals(properties.getContents()))) { cnt += properties.getContents().amount; } } return cnt; }
@Override public void forEachFluid(Consumer<FluidIdentifierStack> fluidStackConsumer) { IFluidTankProperties[] tanks = fluidhandler.getTankProperties(); if(tanks != null) { for(IFluidTankProperties tank : tanks) { if(tank.getContents() != null) { fluidStackConsumer.accept(FluidIdentifierStack.getFromStack(tank.getContents())); } } } }
private int getCapacity(ItemStack stack) { IFluidTankProperties properties = getCapability(stack).getTankProperties()[0]; if (properties.getContents() == null) return 0; else return properties.getContents().amount; }
@Nullable public FluidStack examineLiquid(@Nonnull Inventory inv, @Nullable Integer slot) { IFluidHandler handler = getFluidHandlerAt(inv); if (slot == null) { slot = 0; } IFluidTankProperties[] properties = handler.getTankProperties(); if (properties != null && slot < properties.length) { return properties[slot].getContents(); } return null; }
@Nullable private static String getContentsName(IFluidTankProperties fluidTankProperties) { FluidStack contents = fluidTankProperties.getContents(); if (contents != null) { Fluid fluid = contents.getFluid(); if (fluid != null) { return fluid.getName(); } } return null; } }
@Override public int getLiquid(@Nonnull Inventory side) { IFluidHandler handler = getFluidHandlerAt(side); IFluidTankProperties[] properties = handler.getTankProperties(); if (properties != null && properties.length > 0) { FluidStack contents = properties[0].getContents(); if (contents != null) { return contents.amount; } } return 0; }
public static boolean isEmpty(ItemStack container) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { FluidStack contents = properties.getContents(); if (contents != null && contents.amount > 0) { return false; } } return true; }
@Override public boolean canPutStack(ItemStack stack) { IFluidHandlerItem fluidHandlerItem = FluidUtil.getFluidHandler(stack); return fluidHandlerItem != null && (!requireFilledContainer || fluidHandlerItem.getTankProperties()[0].getContents() != null); } }
@Override public ValueObjectTypeFluidStack.ValueFluidStack get(int index) { return ValueObjectTypeFluidStack.ValueFluidStack.of(getCapability().map(handler -> handler.getTankProperties()[index].getContents()).orElse(null)); } }
public int getFreeSpaceInsideTank(FluidIdentifier type) { int free = 0; IFluidTankProperties[] tanks = fluidhandler.getTankProperties(); if (tanks != null && tanks.length > 0) { for (IFluidTankProperties tank : tanks) { FluidStack content = tank.getContents(); if(content == null || FluidIdentifier.get(content) == type) { free += getFreeSpaceInsideTank(tank); } } } return free; }
@Override public ValueObjectTypeFluidStack.ValueFluidStack get(int index) { return ValueObjectTypeFluidStack.ValueFluidStack.of(getTank().getTankProperties()[index].getContents()); } }
public static FluidStack getFluidStackFromHandler(ItemStack container) { if (isFluidHandler(container)) { IFluidTankProperties[] tank = container.getCapability(FLUID_HANDLER_ITEM, null).getTankProperties(); return tank.length <= 0 ? null : tank[0].getContents(); } return null; }
@Override public String apply(ItemStack itemStack) { IFluidHandlerItem fluidHandler = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if(fluidHandler != null) { IFluidTankProperties fluidTankProperties = fluidHandler.getTankProperties()[0]; FluidStack fluid = fluidTankProperties.getContents(); return String.format("%d;f=%s", itemStack.getMetadata(), fluid == null ? "empty" : fluid.getFluid().getName()); } return String.valueOf(itemStack.getMetadata()); } }
public FluidStack getCurrentFluidStack() { IFluidHandler fluidHandler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP); if (fluidHandler == null || fluidHandler.getTankProperties() == null || fluidHandler.getTankProperties().length == 0) { return null; } return fluidHandler.getTankProperties()[0].getContents(); } }