Package net.minecraft.world.inventory
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ItemStackstatic final intfinal intprivate final List<ContainerListener> private final NonNullList<ItemStack> private static final org.slf4j.Loggerprivate final MenuType<?> static final intstatic final intstatic final intstatic final intstatic final intstatic final intprivate intprivate intprivate RemoteSlotprivate final it.unimi.dsi.fastutil.ints.IntListprivate final NonNullList<RemoteSlot> static final intstatic final intfinal NonNullList<Slot> static final intprivate intprivate booleanprivate ContainerSynchronizer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractContainerMenu(MenuType<?> pMenuType, int pContainerId) -
Method Summary
Modifier and TypeMethodDescriptionprotected DataSlotaddDataSlot(DataSlot pIntValue) protected voidaddDataSlots(ContainerData pArray) protected voidaddInventoryExtendedSlots(Container pContainer, int pX, int pY) protected voidaddInventoryHotbarSlots(Container pContainer, int pX, int pY) protected SlotAdds an item slot to this containervoidaddSlotListener(ContainerListener pListener) protected voidaddStandardInventorySlots(Container pContainer, int pX, int pY) voidvoidbooleanReturnstrueif the player can "drag-spilt" items into this slot.static booleancanItemQuickReplace(Slot pSlot, ItemStack pStack, boolean pStackSizeMatters) Checks if it's possible to add the given itemstack to the given slot.booleancanTakeItemForPickAll(ItemStack pStack, Slot pSlot) Called to determine if the current slot is valid for the stack merging (double-click) code.protected static voidcheckContainerDataCount(ContainerData pIntArray, int pMinSize) protected static voidcheckContainerSize(Container pContainer, int pMinSize) protected voidclearContainer(Player pPlayer, Container pContainer) voidbooleanclickMenuButton(Player pPlayer, int pId) Handles the given Button-click on the server, currently only used by enchanting.private SlotAccessprivate voidprivate static voiddropOrPlaceInInventory(Player pPlayer, ItemStack pStack) getItems()static intgetQuickcraftHeader(int pClickedButton) Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag)static intgetQuickcraftMask(int pQuickCraftingHeader, int pQuickCraftingType) static intgetQuickCraftPlaceCount(Set<Slot> pSlots, int pType, ItemStack pStack) static intgetQuickcraftType(int pEventButton) Extracts the drag mode.static intgetRedstoneSignalFromBlockEntity(BlockEntity pBlockEntity) Like the version that takes an inventory.static intgetRedstoneSignalFromContainer(Container pContainer) getSlot(int pSlotId) intMenuType<?> getType()intvoidinitializeContents(int pStateId, List<ItemStack> pItems, ItemStack pCarried) static booleanisValidQuickcraftType(int pDragMode, Player pPlayer) booleanisValidSlotIndex(int pSlotIndex) protected booleanmoveItemStackTo(ItemStack pStack, int pStartIndex, int pEndIndex, boolean pReverseDirection) Merges provided ItemStack with the first available one in the container/player inventor between minIndex (included) and maxIndex (excluded).abstract ItemStackquickMoveStack(Player pPlayer, int pIndex) Handle when the stack in slotindexis shift-clicked.voidCalled when the container is closed.voidremoveSlotListener(ContainerListener pListener) Remove the given Listener.protected voidvoidvoidvoidsetCarried(ItemStack pStack) voidsetData(int pId, int pData) voidPuts an ItemStack in a slot.voidsetRemoteCarried(HashedStack pStack) voidsetRemoteSlot(int pSlot, ItemStack pStack) voidsetRemoteSlotUnsafe(int pSlot, HashedStack pStack) voidsetSelectedBundleItemIndex(int pSlotIndex, int pBundleItemIndex) voidsetSynchronizer(ContainerSynchronizer pSynchronizer) voidslotsChanged(Container pContainer) Callback for when the crafting matrix is changed.abstract booleanstillValid(Player pPlayer) Determines whether supplied player can use this containerprotected static booleanstillValid(ContainerLevelAccess pAccess, Player pPlayer, Block pTargetBlock) voidprivate voidprivate voidsynchronizeDataSlotToRemote(int pSlotIndex, int pValue) private voidsynchronizeSlotToRemote(int pSlotIndex, ItemStack pStack, Supplier<ItemStack> pSupplier) voidprivate voidtriggerSlotListeners(int pSlotIndex, ItemStack pStack, Supplier<ItemStack> pSupplier) private booleantryItemClickBehaviourOverride(Player pPlayer, ClickAction pAction, Slot pSlot, ItemStack pClickedItem, ItemStack pCarriedItem) private voidupdateDataSlotListeners(int pSlotIndex, int pValue)
-
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
-
slots
-
dataSlots
-
carried
-
remoteSlots
-
remoteDataSlots
private final it.unimi.dsi.fastutil.ints.IntList remoteDataSlots -
remoteCarried
-
stateId
private int stateId -
containerId
public final int containerId -
quickcraftType
private int quickcraftType -
quickcraftStatus
private int quickcraftStatus -
quickcraftSlots
-
containerListeners
-
synchronizer
-
suppressRemoteUpdates
private boolean suppressRemoteUpdates
-
-
Constructor Details
-
AbstractContainerMenu
-
-
Method Details
-
addInventoryHotbarSlots
-
addInventoryExtendedSlots
-
addStandardInventorySlots
-
stillValid
protected static boolean stillValid(ContainerLevelAccess pAccess, Player pPlayer, Block pTargetBlock) -
getType
-
checkContainerSize
-
checkContainerDataCount
-
isValidSlotIndex
public boolean isValidSlotIndex(int pSlotIndex) -
addSlot
Adds an item slot to this container -
addDataSlot
-
addDataSlots
-
addSlotListener
-
setSynchronizer
-
sendAllDataToRemote
public void sendAllDataToRemote() -
removeSlotListener
Remove the given Listener. Method name is for legacy. -
getItems
-
broadcastChanges
public void broadcastChanges() -
broadcastFullState
public void broadcastFullState() -
updateDataSlotListeners
private void updateDataSlotListeners(int pSlotIndex, int pValue) -
triggerSlotListeners
-
synchronizeSlotToRemote
-
synchronizeDataSlotToRemote
private void synchronizeDataSlotToRemote(int pSlotIndex, int pValue) -
synchronizeCarriedToRemote
private void synchronizeCarriedToRemote() -
setRemoteSlot
-
setRemoteSlotUnsafe
-
setRemoteCarried
-
clickMenuButton
Handles the given Button-click on the server, currently only used by enchanting. Name is for legacy. -
getSlot
-
quickMoveStack
Handle when the stack in slotindexis shift-clicked. Normally this moves the stack between the player inventory and the other inventory(s). -
setSelectedBundleItemIndex
public void setSelectedBundleItemIndex(int pSlotIndex, int pBundleItemIndex) -
clicked
-
doClick
-
tryItemClickBehaviourOverride
private boolean tryItemClickBehaviourOverride(Player pPlayer, ClickAction pAction, Slot pSlot, ItemStack pClickedItem, ItemStack pCarriedItem) -
createCarriedSlotAccess
-
canTakeItemForPickAll
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
Called when the container is closed. -
dropOrPlaceInInventory
-
clearContainer
-
slotsChanged
Callback for when the crafting matrix is changed. -
setItem
Puts an ItemStack in a slot. -
initializeContents
-
setData
public void setData(int pId, int pData) -
stillValid
Determines whether supplied player can use this container -
moveItemStackTo
protected boolean moveItemStackTo(ItemStack pStack, int pStartIndex, int pEndIndex, boolean pReverseDirection) 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 pEventButton) Extracts the drag mode. Args : eventButton. Return (0 : evenly split, 1 : one item by slot, 2 : not used ?) -
getQuickcraftHeader
public static int getQuickcraftHeader(int pClickedButton) Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag) -
getQuickcraftMask
public static int getQuickcraftMask(int pQuickCraftingHeader, int pQuickCraftingType) -
isValidQuickcraftType
-
resetQuickCraft
protected void resetQuickCraft() -
canItemQuickReplace
public static boolean canItemQuickReplace(@Nullable Slot pSlot, ItemStack pStack, boolean pStackSizeMatters) Checks if it's possible to add the given itemstack to the given slot. -
getQuickCraftPlaceCount
-
canDragTo
Returnstrueif the player can "drag-spilt" items into this slot. Returnstrueby default. Called to check if the slot can be added to a list of Slots to split the held ItemStack across. -
getRedstoneSignalFromBlockEntity
Like the version that takes an inventory. If the given BlockEntity is not an Inventory, 0 is returned instead. -
getRedstoneSignalFromContainer
-
setCarried
-
getCarried
-
suppressRemoteUpdates
public void suppressRemoteUpdates() -
resumeRemoteUpdates
public void resumeRemoteUpdates() -
transferState
-
findSlot
-
getStateId
public int getStateId() -
incrementStateId
public int incrementStateId()
-