Package net.minecraft.world.inventory
Class AbstractContainerMenu
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
- Direct Known Subclasses:
BeaconMenu
,BrewingStandMenu
,CartographyTableMenu
,ChestMenu
,ContainerTypeTest.TestContainer
,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<?> pMenuType, int pContainerId) -
Method Summary
Modifier and TypeMethodDescriptionprotected DataSlot
addDataSlot
(DataSlot pIntValue) protected void
addDataSlots
(ContainerData pArray) protected Slot
Adds an item slot to this containervoid
addSlotListener
(ContainerListener pListener) void
void
boolean
Returnstrue
if the player can "drag-spilt" items into this slot.static boolean
canItemQuickReplace
(Slot pSlot, ItemStack pStack, boolean pStackSizeMatters) Checks if it's possible to add the given itemstack to the given slot.boolean
canTakeItemForPickAll
(ItemStack pStack, Slot pSlot) Called to determine if the current slot is valid for the stack merging (double-click) code.protected static void
checkContainerDataCount
(ContainerData pIntArray, int pMinSize) protected static void
checkContainerSize
(Container pContainer, int pMinSize) protected void
clearContainer
(Player pPlayer, Container pContainer) void
boolean
clickMenuButton
(Player pPlayer, int pId) Handles the given Button-click on the server, currently only used by enchanting.private SlotAccess
private void
getItems()
static int
getQuickcraftHeader
(int pClickedButton) Args : clickedButton, Returns (0 : start drag, 1 : add slot, 2 : end drag)static int
getQuickcraftMask
(int pQuickCraftingHeader, int pQuickCraftingType) static int
getQuickCraftPlaceCount
(Set<Slot> pSlots, int pType, ItemStack pStack) static int
getQuickcraftType
(int pEventButton) Extracts the drag mode.static int
getRedstoneSignalFromBlockEntity
(BlockEntity pBlockEntity) Like the version that takes an inventory.static int
getRedstoneSignalFromContainer
(Container pContainer) getSlot
(int pSlotId) int
MenuType
<?> getType()
int
void
initializeContents
(int pStateId, List<ItemStack> pItems, ItemStack pCarried) static boolean
isValidQuickcraftType
(int pDragMode, Player pPlayer) boolean
isValidSlotIndex
(int pSlotIndex) 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).abstract ItemStack
quickMoveStack
(Player pPlayer, int pIndex) Handle when the stack in slotindex
is shift-clicked.void
Called when the container is closed.void
removeSlotListener
(ContainerListener pListener) Remove the given Listener.protected void
void
void
void
setCarried
(ItemStack pStack) void
setData
(int pId, int pData) void
Puts an ItemStack in a slot.void
setRemoteCarried
(ItemStack pRemoteCarried) void
setRemoteSlot
(int pSlot, ItemStack pStack) void
setRemoteSlotNoCopy
(int pSlot, ItemStack pStack) void
setSynchronizer
(ContainerSynchronizer pSynchronizer) void
slotsChanged
(Container pContainer) Callback for when the crafting matrix is changed.abstract boolean
stillValid
(Player pPlayer) Determines whether supplied player can use this containerprotected static boolean
stillValid
(ContainerLevelAccess pAccess, Player pPlayer, Block pTargetBlock) void
private void
private void
synchronizeDataSlotToRemote
(int pSlotIndex, int pValue) private void
synchronizeSlotToRemote
(int pSlotIndex, ItemStack pStack, Supplier<ItemStack> pSupplier) void
private void
triggerSlotListeners
(int pSlotIndex, ItemStack pStack, Supplier<ItemStack> pSupplier) private boolean
tryItemClickBehaviourOverride
(Player pPlayer, ClickAction pAction, Slot pSlot, ItemStack pClickedItem, ItemStack pCarriedItem) private void
updateDataSlotListeners
(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:
-
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
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
-
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 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. -
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, negativDirection. [!] 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
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()
-