类 StackCopySlot

java.lang.Object
net.minecraft.world.inventory.Slot
net.neoforged.neoforge.items.StackCopySlot
直接已知子类:
ItemHandlerCopySlot

public abstract class StackCopySlot extends Slot
Slot to handle immutable itemstack storages (Ex: ComponentItemHandler).

For an implementation for use with an IItemHandler see ItemHandlerCopySlot.

Vanilla MC code modifies the stack returned by `getStack()` directly, but it calls setChanged() when that happens, so we just cache the returned stack, and set it when setChanged() is called.

  • 字段详细资料

    • emptyInventory

      private static final Container emptyInventory
    • cachedReturnedStack

      @Nullable private @Nullable ItemStack cachedReturnedStack
  • 构造器详细资料

    • StackCopySlot

      public StackCopySlot(int x, int y)
  • 方法详细资料

    • getStackCopy

      protected abstract ItemStack getStackCopy()
      Gets the itemstack from the storage.
      返回:
      the stack in this slot
    • setStackCopy

      protected abstract void setStackCopy(ItemStack stack)
      Sets the itemstack from the storage.
      参数:
      stack - the stack to put into this slot
    • getItem

      public final ItemStack getItem()
      覆盖:
      getItem 在类中 Slot
    • set

      public final void set(ItemStack stack)
      覆盖:
      set 在类中 Slot
    • setChanged

      public final void setChanged()
      覆盖:
      setChanged 在类中 Slot
    • remove

      public final ItemStack remove(int amount)
      覆盖:
      remove 在类中 Slot