Class AbstractContainerMenu

java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
Direct Known Subclasses:
AbstractMountInventoryMenu, BeaconMenu, BrewingStandMenu, CartographyTableMenu, ChestMenu, CrafterMenu, CreativeModeInventoryScreen.ItemPickerMenu, DispenserMenu, EnchantmentMenu, GrindstoneMenu, HopperMenu, 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:
    • SLOTS_PER_ROW

      public static final int SLOTS_PER_ROW
      See Also:
    • SLOT_SIZE

      public static final int 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<RemoteSlot> remoteSlots
    • remoteDataSlots

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

      private RemoteSlot 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

      private @Nullable ContainerSynchronizer synchronizer
    • suppressRemoteUpdates

      private boolean suppressRemoteUpdates
  • Constructor Details

    • AbstractContainerMenu

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

    • addInventoryHotbarSlots

      protected void addInventoryHotbarSlots(Container inventory, int left, int top)
    • addInventoryExtendedSlots

      protected void addInventoryExtendedSlots(Container inventory, int left, int top)
    • addStandardInventorySlots

      protected void addStandardInventorySlots(Container container, int left, int top)
    • stillValid

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

      public MenuType<?> getType()
    • checkContainerSize

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

      protected static void checkContainerDataCount(ContainerData data, int expected)
    • isValidSlotIndex

      public boolean isValidSlotIndex(int slotIndex)
    • addSlot

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

      protected DataSlot addDataSlot(DataSlot dataSlot)
    • addDataSlots

      protected void addDataSlots(ContainerData container)
    • 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 id, int currentValue)
    • triggerSlotListeners

      private void triggerSlotListeners(int i, ItemStack current, Supplier<ItemStack> currentCopy)
    • synchronizeSlotToRemote

      private void synchronizeSlotToRemote(int i, ItemStack current, Supplier<ItemStack> currentCopy)
    • synchronizeDataSlotToRemote

      private void synchronizeDataSlotToRemote(int i, int current)
    • synchronizeCarriedToRemote

      private void synchronizeCarriedToRemote()
    • setRemoteSlot

      public void setRemoteSlot(int slot, ItemStack itemStack)
    • setRemoteSlotUnsafe

      public void setRemoteSlotUnsafe(int slot, HashedStack itemStack)
    • setRemoteCarried

      public void setRemoteCarried(HashedStack carriedItem)
    • clickMenuButton

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

      public Slot getSlot(int index)
    • quickMoveStack

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

      public void setSelectedBundleItemIndex(int slotIndex, int selectedItemIndex)
    • clicked

      public void clicked(int slotIndex, int buttonNum, ContainerInput containerInput, Player player)
    • doClick

      private void doClick(int slotIndex, int buttonNum, ContainerInput containerInput, Player player)
    • tryItemClickBehaviourOverride

      private boolean tryItemClickBehaviourOverride(Player player, ClickAction clickAction, Slot slot, ItemStack clicked, ItemStack carried)
    • createCarriedSlotAccess

      private SlotAccess createCarriedSlotAccess()
    • canTakeItemForPickAll

      public boolean canTakeItemForPickAll(ItemStack carried, Slot target)
      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.
    • dropOrPlaceInInventory

      private static void dropOrPlaceInInventory(Player player, ItemStack carried)
    • 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 slot, int stateId, ItemStack itemStack)
      Puts an ItemStack in a slot.
    • initializeContents

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

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

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

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

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

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

      public static int getQuickcraftMask(int header, int type)
    • isValidQuickcraftType

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

      protected void resetQuickCraft()
    • canItemQuickReplace

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

      public static int getQuickCraftPlaceCount(int quickCraftSlotsSize, int quickCraftingType, ItemStack itemStack)
    • 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 carried)
    • getCarried

      public ItemStack getCarried()
    • suppressRemoteUpdates

      public void suppressRemoteUpdates()
    • resumeRemoteUpdates

      public void resumeRemoteUpdates()
    • transferState

      public void transferState(AbstractContainerMenu otherContainer)
    • findSlot

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

      public int getStateId()
    • incrementStateId

      public int incrementStateId()