@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; }
public List<IAEFluidStack> update() final IFluidTankProperties[] tankProperties = this.fluidHandler.getTankProperties(); final int slots = tankProperties.length;
private int createHandlerHash( TileEntity target ) { if( target == null ) { return 0; } final EnumFacing targetSide = this.getSide().getFacing().getOpposite(); if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) ) { return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) ); } final IFluidHandler fluidHandler = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ); if( fluidHandler != null ) { return Objects.hash( target, fluidHandler, fluidHandler.getTankProperties().length ); } return 0; }
@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; }
boolean changed = false; final IFluidTankProperties[] props = this.handler.getTankProperties(); for( int slot = 0; slot < this.handler.getTankProperties().length; ++slot )
@Override public boolean containsTanks() { IFluidTankProperties[] tanks = fluidhandler.getTankProperties(); return tanks != null && tanks.length > 0; }
private static boolean canDrain(IFluidHandler fluidHandler) { for (IFluidTankProperties properties : fluidHandler.getTankProperties()) { if (properties.canDrain()) { return true; } } return false; }
private static boolean canFill(IFluidHandler fluidHandler) { for (IFluidTankProperties properties : fluidHandler.getTankProperties()) { if (properties.canFill()) { return true; } } return false; } }
@Override public IFluidTankProperties[] getTankProperties() { IFluidTankProperties[] internalTankProperties = internalFluidHandler.getTankProperties(); IFluidTankProperties[] tankProperties = new IFluidTankProperties[internalTankProperties.length]; for (int i = 0; i < internalTankProperties.length; i++) { IFluidTankProperties fluidTankProperties = internalTankProperties[i]; tankProperties[i] = new DrainOnlyFluidPropertiesWrapper(fluidTankProperties); } return tankProperties; }
@Override public int getLength() { IFluidHandler tank = getTank(); if(tank == null) { return 0; } IFluidTankProperties[] tanks = tank.getTankProperties(); if(tanks == null) { return 0; } return tanks.length; }
@Nonnull @Override public Map<Object, Object> getMeta(@Nonnull IPartialContext<IFluidHandler> context) { IFluidHandler handler = context.getTarget(); Map<Object, Object> tanks = Maps.newHashMap(); int i = 0; for (IFluidTankProperties tank : handler.getTankProperties()) { tanks.put(++i, context.makePartialChild(tank).getMeta()); } return tanks; }
@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; }
@Override public boolean canDrain(FluidIdentifier fluid) { IFluidTankProperties[] tanks = fluidhandler.getTankProperties(); if(tanks != null) { for(IFluidTankProperties tank : tanks) { if(tank.canDrainFluidType(fluid.makeFluidStack(1))) { return true; } } } return false; }
public static boolean isDrainableContainer(ItemStack container) { IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler == null) { return false; } IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties(); for (IFluidTankProperties properties : tankProperties) { if (properties.canDrain()) { return true; } } return false; }
@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 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 ValueTypeInteger.ValueInteger get(int index) { return ValueTypeInteger.ValueInteger.of(getTank().getTankProperties()[index].getCapacity()); } }
private int getCapacity(ItemStack stack) { IFluidTankProperties properties = getCapability(stack).getTankProperties()[0]; if (properties.getContents() == null) return 0; else return properties.getContents().amount; }
@Override public ValueObjectTypeFluidStack.ValueFluidStack get(int index) { return ValueObjectTypeFluidStack.ValueFluidStack.of(getTank().getTankProperties()[index].getContents()); } }
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; }