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 ItemStackprivate final it.unimi.dsi.fastutil.ints.IntListprivate final NonNullList<ItemStack> static final intfinal NonNullList<Slot> private intprivate booleanprivate ContainerSynchronizer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractContainerMenu(MenuType<?> menuType, int containerId) -
Method Summary
Modifier and TypeMethodDescriptionprotected DataSlotaddDataSlot(DataSlot intValue) protected voidaddDataSlots(ContainerData array) protected SlotAdds an item slot to this containervoidaddSlotListener(ContainerListener listener) voidvoidbooleanReturnstrueif the player can "drag-spilt" items into this slot.static booleancanItemQuickReplace(Slot slot, ItemStack stack, boolean stackSizeMatters) Checks if it's possible to add the given itemstack to the given slot.booleancanTakeItemForPickAll(ItemStack stack, Slot slot) Called to determine if the current slot is valid for the stack merging (double-click) code.protected static voidcheckContainerDataCount(ContainerData intArray, int minSize) protected static voidcheckContainerSize(Container container, int minSize) protected voidclearContainer(Player player, Container container) voidbooleanclickMenuButton(Player player, int id) Handles the given Button-click on the server, currently only used by enchanting.private SlotAccessprivate voidgetItems()static intgetQuickcraftHeader(int clickedButton) Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag)static intgetQuickcraftMask(int quickCraftingHeader, int quickCraftingType) static intgetQuickCraftPlaceCount(Set<Slot> slots, int type, ItemStack stack) static intgetQuickcraftType(int eventButton) Extracts the drag mode.static intgetRedstoneSignalFromBlockEntity(BlockEntity blockEntity) Like the version that takes an inventory.static intgetRedstoneSignalFromContainer(Container container) getSlot(int slotId) intMenuType<?> getType()intvoidinitializeContents(int stateId, List<ItemStack> items, ItemStack carried) static booleanisValidQuickcraftType(int dragMode, Player player) booleanisValidSlotIndex(int slotIndex) protected booleanmoveItemStackTo(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).abstract ItemStackquickMoveStack(Player player, int index) Handle when the stack in slotindexis shift-clicked.voidCalled when the container is closed.voidremoveSlotListener(ContainerListener listener) Remove the given Listener.protected voidvoidvoidvoidsetCarried(ItemStack stack) voidsetData(int id, int data) voidPuts an ItemStack in a slot.voidsetRemoteCarried(ItemStack remoteCarried) voidsetRemoteSlot(int slot, ItemStack stack) voidsetRemoteSlotNoCopy(int slot, ItemStack stack) voidsetSynchronizer(ContainerSynchronizer synchronizer) voidslotsChanged(Container container) Callback for when the crafting matrix is changed.abstract booleanstillValid(Player player) Determines whether supplied player can use this containerprotected static booleanstillValid(ContainerLevelAccess access, Player player, Block targetBlock) voidprivate voidprivate voidsynchronizeDataSlotToRemote(int slotIndex, int value) private voidsynchronizeSlotToRemote(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier) voidprivate voidtriggerSlotListeners(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier) private booleantryItemClickBehaviourOverride(Player player, ClickAction action, Slot slot, ItemStack clickedItem, ItemStack carriedItem) private voidupdateDataSlotListeners(int slotIndex, int value)
-
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
-
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
-
stillValid
-
getType
-
checkContainerSize
-
checkContainerDataCount
-
isValidSlotIndex
public boolean isValidSlotIndex(int slotIndex) -
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 slotIndex, int value) -
triggerSlotListeners
-
synchronizeSlotToRemote
-
synchronizeDataSlotToRemote
private void synchronizeDataSlotToRemote(int slotIndex, int value) -
synchronizeCarriedToRemote
private void synchronizeCarriedToRemote() -
setRemoteSlot
-
setRemoteSlotNoCopy
-
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). -
clicked
-
doClick
-
tryItemClickBehaviourOverride
private boolean tryItemClickBehaviourOverride(Player player, ClickAction action, Slot slot, ItemStack clickedItem, ItemStack carriedItem) -
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. -
clearContainer
-
slotsChanged
Callback for when the crafting matrix is changed. -
setItem
Puts an ItemStack in a slot. -
initializeContents
-
setData
public void setData(int id, int data) -
stillValid
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
-
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
-
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()
-