Interface BlockEntityInventory<T extends BlockEntity & Carrier>

Type Parameters:
T - Block entity type, the specified BE must be a Carrier
All Superinterfaces:
CarriedInventory<T>, Inventory, PersistentInventory, ValueContainer, ViewableInventory

public interface BlockEntityInventory<T extends BlockEntity & Carrier> extends PersistentInventory, ViewableInventory, CarriedInventory<T>
An Inventory which is owned by a BlockEntity. In Sponge, a BE is never seen as an Inventory itself and Block Entities are instead considered to "own" their own Inventory (much like equipable entities do). Underlying implementations are of course completely at liberty to return the BE object directly but as far as consumers are concerned the BE instance and the inventory are separate things.

This is intended to provide a consistent way of dealing with inventories regardless of the "owner" of the inventory. Thus, any code capable of dealing with a Carrier is intrinsically able to deal with a BE inventory just as they would with any Entity inventory or any other type of Carrier for that matter.

This separation of inventory logic from the BE itself also serves to provide some flexibility for implementors, since it is possible that not all implementations may take the view that a BE embodies its own inventory.

  • Method Details

    • blockEntity

      Optional<T> blockEntity()
      Returns the owner of this Inventory.
      Returns:
      This inventory's carrier