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 ItemStack
static final int
final int
private final List
<ContainerListener> private final NonNullList
<ItemStack> private static final org.slf4j.Logger
private final MenuType
<?> static final int
static final int
static final int
static final int
static final int
static final int
private int
private int
private ItemStack
private final it.unimi.dsi.fastutil.ints.IntList
private final NonNullList
<ItemStack> static final int
final NonNullList
<Slot> private int
private boolean
private ContainerSynchronizer
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractContainerMenu
(MenuType<?> menuType, int containerId) -
Method Summary
Modifier and TypeMethodDescriptionprotected DataSlot
addDataSlot
(DataSlot intValue) protected void
addDataSlots
(ContainerData array) protected Slot
Adds an item slot to this containervoid
addSlotListener
(ContainerListener listener) void
void
boolean
Returnstrue
if the player can "drag-spilt" items into this slot.static boolean
canItemQuickReplace
(Slot slot, ItemStack stack, boolean stackSizeMatters) Checks if it's possible to add the given itemstack to the given slot.boolean
canTakeItemForPickAll
(ItemStack stack, Slot slot) Called to determine if the current slot is valid for the stack merging (double-click) code.protected static void
checkContainerDataCount
(ContainerData intArray, int minSize) protected static void
checkContainerSize
(Container container, int minSize) protected void
clearContainer
(Player player, Container container) void
boolean
clickMenuButton
(Player player, int id) Handles the given Button-click on the server, currently only used by enchanting.private SlotAccess
private void
getItems()
static int
getQuickcraftHeader
(int clickedButton) Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag)static int
getQuickcraftMask
(int quickCraftingHeader, int quickCraftingType) static int
getQuickCraftPlaceCount
(Set<Slot> slots, int type, ItemStack stack) static int
getQuickcraftType
(int eventButton) Extracts the drag mode.static int
getRedstoneSignalFromBlockEntity
(BlockEntity blockEntity) Like the version that takes an inventory.static int
getRedstoneSignalFromContainer
(Container container) getSlot
(int slotId) int
MenuType
<?> getType()
int
void
initializeContents
(int stateId, List<ItemStack> items, ItemStack carried) static boolean
isValidQuickcraftType
(int dragMode, Player player) boolean
isValidSlotIndex
(int slotIndex) 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).abstract ItemStack
quickMoveStack
(Player player, int index) Handle when the stack in slotindex
is shift-clicked.void
Called when the container is closed.void
removeSlotListener
(ContainerListener listener) Remove the given Listener.protected void
void
void
void
setCarried
(ItemStack stack) void
setData
(int id, int data) void
Puts an ItemStack in a slot.void
setRemoteCarried
(ItemStack remoteCarried) void
setRemoteSlot
(int slot, ItemStack stack) void
setRemoteSlotNoCopy
(int slot, ItemStack stack) void
setSynchronizer
(ContainerSynchronizer synchronizer) void
slotsChanged
(Container container) Callback for when the crafting matrix is changed.abstract boolean
stillValid
(Player player) Determines whether supplied player can use this containerprotected static boolean
stillValid
(ContainerLevelAccess access, Player player, Block targetBlock) void
private void
private void
synchronizeDataSlotToRemote
(int slotIndex, int value) private void
synchronizeSlotToRemote
(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier) void
private void
triggerSlotListeners
(int slotIndex, ItemStack stack, Supplier<ItemStack> supplier) private boolean
tryItemClickBehaviourOverride
(Player player, ClickAction action, Slot slot, ItemStack clickedItem, ItemStack carriedItem) private void
updateDataSlotListeners
(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 slotindex
is 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
Returnstrue
if the player can "drag-spilt" items into this slot. Returnstrue
by 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()
-