Class AbstractContainerMenu

java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
Direct Known Subclasses:
BeaconMenu, BrewingStandMenu, CartographyTableMenu, ChestMenu, CrafterMenu, CreativeModeInventoryScreen.ItemPickerMenu, DispenserMenu, EnchantmentMenu, GrindstoneMenu, HopperMenu, HorseInventoryMenu, ItemCombinerMenu, LecternMenu, LoomMenu, MerchantMenu, RecipeBookMenu, ShulkerBoxMenu, StonecutterMenu

public abstract class AbstractContainerMenu extends Object
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • SLOT_CLICKED_OUTSIDE

      public static final int SLOT_CLICKED_OUTSIDE
      See Also:
    • QUICKCRAFT_TYPE_CHARITABLE

      public static final int QUICKCRAFT_TYPE_CHARITABLE
      See Also:
    • QUICKCRAFT_TYPE_GREEDY

      public static final int QUICKCRAFT_TYPE_GREEDY
      See Also:
    • QUICKCRAFT_TYPE_CLONE

      public static final int QUICKCRAFT_TYPE_CLONE
      See Also:
    • QUICKCRAFT_HEADER_START

      public static final int QUICKCRAFT_HEADER_START
      See Also:
    • QUICKCRAFT_HEADER_CONTINUE

      public static final int QUICKCRAFT_HEADER_CONTINUE
      See Also:
    • QUICKCRAFT_HEADER_END

      public static final int QUICKCRAFT_HEADER_END
      See Also:
    • CARRIED_SLOT_SIZE

      public static final int CARRIED_SLOT_SIZE
      See Also:
    • lastSlots

      private final NonNullList<ItemStack> lastSlots
    • slots

      public final NonNullList<Slot> slots
    • dataSlots

      private final List<DataSlot> dataSlots
    • carried

      private ItemStack carried
    • remoteSlots

      private final NonNullList<ItemStack> remoteSlots
    • remoteDataSlots

      private final it.unimi.dsi.fastutil.ints.IntList remoteDataSlots
    • remoteCarried

      private ItemStack remoteCarried
    • stateId

      private int stateId
    • containerId

      public final int containerId
    • quickcraftType

      private int quickcraftType
    • quickcraftStatus

      private int quickcraftStatus
    • quickcraftSlots

      private final Set<Slot> quickcraftSlots
    • containerListeners

      private final List<ContainerListener> containerListeners
    • synchronizer

      @Nullable private ContainerSynchronizer synchronizer
    • suppressRemoteUpdates

      private boolean suppressRemoteUpdates
  • Constructor Details

    • AbstractContainerMenu

      protected AbstractContainerMenu(@Nullable MenuType<?> menuType, int containerId)
  • Method Details

    • stillValid

      protected static boolean stillValid(ContainerLevelAccess access, Player player, Block targetBlock)
    • getType

      public MenuType<?> getType()
    • checkContainerSize

      protected static void checkContainerSize(Container container, int minSize)
    • checkContainerDataCount

      protected static void checkContainerDataCount(ContainerData intArray, int minSize)
    • isValidSlotIndex

      public boolean isValidSlotIndex(int slotIndex)
    • addSlot

      protected Slot addSlot(Slot slot)
      Adds an item slot to this container
    • addDataSlot

      protected DataSlot addDataSlot(DataSlot intValue)
    • addDataSlots

      protected void addDataSlots(ContainerData array)
    • addSlotListener

      public void addSlotListener(ContainerListener listener)
    • setSynchronizer

      public void setSynchronizer(ContainerSynchronizer synchronizer)
    • sendAllDataToRemote

      public void sendAllDataToRemote()
    • removeSlotListener

      public void removeSlotListener(ContainerListener listener)
      Remove the given Listener. Method name is for legacy.
    • getItems

      public NonNullList<ItemStack> getItems()
    • broadcastChanges

      public void broadcastChanges()
    • broadcastFullState

      public void broadcastFullState()
    • updateDataSlotListeners

      private void updateDataSlotListeners(int slotIndex, int value)
    • triggerSlotListeners

      private void triggerSlotListeners(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier)
    • synchronizeSlotToRemote

      private void synchronizeSlotToRemote(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier)
    • synchronizeDataSlotToRemote

      private void synchronizeDataSlotToRemote(int slotIndex, int value)
    • synchronizeCarriedToRemote

      private void synchronizeCarriedToRemote()
    • setRemoteSlot

      public void setRemoteSlot(int slot, ItemStack stack)
    • setRemoteSlotNoCopy

      public void setRemoteSlotNoCopy(int slot, ItemStack stack)
    • setRemoteCarried

      public void setRemoteCarried(ItemStack remoteCarried)
    • clickMenuButton

      public boolean clickMenuButton(Player player, int id)
      Handles the given Button-click on the server, currently only used by enchanting. Name is for legacy.
    • getSlot

      public Slot getSlot(int slotId)
    • quickMoveStack

      public abstract ItemStack quickMoveStack(Player player, int index)
      Handle when the stack in slot index is shift-clicked. Normally this moves the stack between the player inventory and the other inventory(s).
    • clicked

      public void clicked(int slotId, int button, ClickType clickType, Player player)
    • doClick

      private void doClick(int slotId, int button, ClickType clickType, Player player)
    • tryItemClickBehaviourOverride

      private boolean tryItemClickBehaviourOverride(Player player, ClickAction action, Slot slot, ItemStack clickedItem, ItemStack carriedItem)
    • createCarriedSlotAccess

      private SlotAccess createCarriedSlotAccess()
    • canTakeItemForPickAll

      public boolean canTakeItemForPickAll(ItemStack stack, Slot slot)
      Called to determine if the current slot is valid for the stack merging (double-click) code. The stack passed in is null for the initial slot that was double-clicked.
    • removed

      public void removed(Player player)
      Called when the container is closed.
    • clearContainer

      protected void clearContainer(Player player, Container container)
    • slotsChanged

      public void slotsChanged(Container container)
      Callback for when the crafting matrix is changed.
    • setItem

      public void setItem(int slotId, int stateId, ItemStack stack)
      Puts an ItemStack in a slot.
    • initializeContents

      public void initializeContents(int stateId, List<ItemStack> items, ItemStack carried)
    • setData

      public void setData(int id, int data)
    • stillValid

      public abstract boolean stillValid(Player player)
      Determines whether supplied player can use this container
    • moveItemStackTo

      protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection)
      Merges provided ItemStack with the first available one in the container/player inventor between minIndex (included) and maxIndex (excluded). Args : stack, minIndex, maxIndex, negativDirection. [!] the Container implementation do not check if the item is valid for the slot
    • getQuickcraftType

      public static int getQuickcraftType(int eventButton)
      Extracts the drag mode. Args : eventButton. Return (0 : evenly split, 1 : one item by slot, 2 : not used ?)
    • getQuickcraftHeader

      public static int getQuickcraftHeader(int clickedButton)
      Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag)
    • getQuickcraftMask

      public static int getQuickcraftMask(int quickCraftingHeader, int quickCraftingType)
    • isValidQuickcraftType

      public static boolean isValidQuickcraftType(int dragMode, Player player)
    • resetQuickCraft

      protected void resetQuickCraft()
    • canItemQuickReplace

      public static boolean canItemQuickReplace(@Nullable Slot slot, ItemStack stack, boolean stackSizeMatters)
      Checks if it's possible to add the given itemstack to the given slot.
    • getQuickCraftPlaceCount

      public static int getQuickCraftPlaceCount(Set<Slot> slots, int type, ItemStack stack)
    • canDragTo

      public boolean canDragTo(Slot slot)
      Returns true if the player can "drag-spilt" items into this slot. Returns true by default. Called to check if the slot can be added to a list of Slots to split the held ItemStack across.
    • getRedstoneSignalFromBlockEntity

      public static int getRedstoneSignalFromBlockEntity(@Nullable BlockEntity blockEntity)
      Like the version that takes an inventory. If the given BlockEntity is not an Inventory, 0 is returned instead.
    • getRedstoneSignalFromContainer

      public static int getRedstoneSignalFromContainer(@Nullable Container container)
    • setCarried

      public void setCarried(ItemStack stack)
    • getCarried

      public ItemStack getCarried()
    • suppressRemoteUpdates

      public void suppressRemoteUpdates()
    • resumeRemoteUpdates

      public void resumeRemoteUpdates()
    • transferState

      public void transferState(AbstractContainerMenu menu)
    • findSlot

      public OptionalInt findSlot(Container container, int slotIndex)
    • getStateId

      public int getStateId()
    • incrementStateId

      public int incrementStateId()