Class ItemFluidContainer

java.lang.Object
net.minecraftforge.registries.ForgeRegistryEntry<Item>
net.minecraft.item.Item
net.minecraftforge.fluids.capability.ItemFluidContainer
All Implemented Interfaces:
IItemProvider, IForgeItem, IForgeRegistryEntry<Item>

public class ItemFluidContainer extends Item
A simple fluid container, to replace the functionality of the old FluidContainerRegistry and IFluidContainerItem. This fluid container may be set so that is can only completely filled or empty. (binary) It may also be set so that it gets consumed when it is drained. (consumable)
  • Field Details

    • capacity

      protected final int capacity
  • Constructor Details

    • ItemFluidContainer

      public ItemFluidContainer(Item.Properties properties, int capacity)
      Parameters:
      capacity - The maximum capacity of this fluid container.
  • Method Details

    • initCapabilities

      public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundNBT nbt)
      Description copied from interface: IForgeItem
      Called from ItemStack.setItem, will hold extra data for the life of this ItemStack. Can be retrieved from stack.getCapabilities() The NBT can be null if this is not called from readNBT or if the item the stack is changing FROM is different then this item, or the previous item had no capabilities. This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item. Remember that getItem CAN return null.
      Parameters:
      stack - The ItemStack
      nbt - NBT of this item serialized, or null.
      Returns:
      A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.