Class ItemStorage

java.lang.Object
net.fabricmc.fabric.api.transfer.v1.item.ItemStorage

@Experimental public final class ItemStorage extends Object
Access to Storage<ItemVariant> instances.

Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.

  • Field Details

    • SIDED

      public static final BlockApiLookup<Storage<ItemVariant>,net.minecraft.util.math.Direction> SIDED
      Sided block access to item variant storages. The Direction parameter may never be null. Refer to BlockApiLookup for documentation on how to use this field.

      When the operations supported by a storage change, that is if the return value of Storage.supportsInsertion() or Storage.supportsExtraction() changes, the storage should notify its neighbors with a block update so that they can refresh their connections if necessary.

      Block entities directly implementing Inventory or SidedInventory are automatically handled by a fallback provider, and don't need to do anything. Blocks that implement InventoryProvider and whose returned inventory is constant (it's the same for two subsequent calls) are also handled automatically and don't need to do anything. The fallback provider assumes that the Inventory "owns" its contents. If that's not the case, for example because it redirects all function calls to another inventory, then implementing Inventory should be avoided.

      Hoppers and droppers will interact with storages exposed through this lookup, thus implementing one of the vanilla APIs is not necessary.

      Depending on the use case, the following strategies can be used to offer a Storage<ItemVariant> implementation: