Interface ContainerExtension

All Known Subinterfaces:
Container, ContainerEntity, ContainerSingleItem, ContainerSingleItem.BlockContainerSingleItem, CraftingContainer, Hopper, ListBackedContainer, RandomizableContainer, WorldlyContainer
All Known Implementing Classes:
AbstractChestBoat, AbstractFurnaceBlockEntity, AbstractMinecartContainer, BarrelBlockEntity, BaseContainerBlockEntity, BlastFurnaceBlockEntity, BrewingStandBlockEntity, ChestBlockEntity, ChestBoat, ChestRaft, ChiseledBookShelfBlockEntity, ComposterBlock.EmptyContainer, ComposterBlock.InputContainer, ComposterBlock.OutputContainer, CompoundContainer, CrafterBlockEntity, DecoratedPotBlockEntity, DispenserBlockEntity, DropperBlockEntity, FurnaceBlockEntity, HopperBlockEntity, Inventory, JukeboxBlockEntity, MerchantContainer, MinecartChest, MinecartHopper, PlayerEnderChestContainer, RandomizableContainerBlockEntity, ResultContainer, ShelfBlockEntity, ShulkerBoxBlockEntity, SimpleContainer, SmokerBlockEntity, TransientCraftingContainer, TrappedChestBlockEntity

public interface ContainerExtension
Extension methods for Container. These methods are used by VanillaContainerWrapper, to allow containers to be integrated in a transaction.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    onTransfer(int slot, int amountChange, TransactionContext transaction)
    Perform additional logic during the transaction, immediately after a successful transfer (i.e.
    private Container
     
    default void
    setItem(int slot, ItemStack stack, boolean insideTransaction)
    An extension of Container.setItem(int, ItemStack) that allows non-transactional side-effects to be skipped.
  • Method Details

    • self

      private Container self()
    • setItem

      @OverrideOnly default void setItem(int slot, ItemStack stack, boolean insideTransaction)
      An extension of Container.setItem(int, ItemStack) that allows non-transactional side-effects to be skipped. Non-transactional side-effects include for example calling setChanged or making changes to the world.
      Parameters:
      insideTransaction - When true, non-transactional actions should be deferred. When false, non-transactional actions can be performed immediately.
      See Also:
    • onTransfer

      @OverrideOnly default void onTransfer(int slot, int amountChange, TransactionContext transaction)
      Perform additional logic during the transaction, immediately after a successful transfer (i.e. insert or extract with result > 0). Any logic performed by this method should be fully transactional, and support being rolled back. In other words, the transaction is still ongoing.
      Parameters:
      amountChange - If positive, the amount of items that were just inserted into this slot. If negative, minus the amount of items that were just extracted from this slot.