Class StorageMenu
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
net.ixdarklord.coolcatcore.api.menu.StorageMenu
public class StorageMenu
extends net.minecraft.world.inventory.AbstractContainerMenu
The menu a
StorageMenuDefinition opens on a block's or an item's inventory. On the server its slots are the
real container; on the client, a copy vanilla keeps in sync. Screens read synced values with get(Attachment)
and getValue(String, Object).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat a menu is open on: a block entity (by position), or the stack in one of the player's inventory slots. -
Field Summary
Fields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, CONTAINER_CLICK_PRIMARY, CONTAINER_CLICK_SECONDARY, containerId, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, SLOT_SIZE, slots, SLOTS_PER_ROW -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStorageMenu(StorageMenuDefinition definition, int containerId, net.minecraft.world.entity.player.Inventory inventory, StorageMenu.Source source, net.minecraft.world.Container container, @Nullable net.minecraft.world.Container opened) -
Method Summary
Modifier and TypeMethodDescriptionThe attachments of what the menu is open on: the block entity or the stack.voidvoidvoidclicked(int slotIndex, int buttonNum, net.minecraft.world.inventory.ContainerInput input, net.minecraft.world.entity.player.Player player) booleanclickMenuButton(net.minecraft.world.entity.player.Player player, int buttonId) <T> Tget(Attachment<T> attachment) An attachment of the block entity or stack: on clients, the value the menu synced (if its definition syncs it), or else the one the client has.net.minecraft.world.ContainerThe inventory the slots show: the real one on the server, the synced copy on the client.intThe number of container slots before the player's inventory slots.net.minecraft.world.entity.player.Player<T> TA value synced withStorageMenuDefinition.Builder.syncValue(String, StreamCodec, T, Function): read on the server, received on clients.protected voidCalled on the client after synced values arrived.net.minecraft.world.item.ItemStackquickMoveStack(net.minecraft.world.entity.player.Player player, int slotIndex) voidreceiveValues(List<StorageMenuValuesPayload.Entry> entries, net.minecraft.core.RegistryAccess registries) Values from the server.voidremoved(net.minecraft.world.entity.player.Player player) voidbooleanstillValid(net.minecraft.world.entity.player.Player player) Methods inherited from class net.minecraft.world.inventory.AbstractContainerMenu
addDataSlot, addDataSlots, addInventoryExtendedSlots, addInventoryHotbarSlots, addSlot, addSlotListener, addStandardInventorySlots, canDragTo, canItemQuickReplace, canTakeItemForPickAll, checkContainerDataCount, checkContainerSize, clearContainer, findSlot, getCarried, getItems, getQuickcraftHeader, getQuickcraftMask, getQuickCraftPlaceCount, getQuickcraftType, getRedstoneSignalFromBlockEntity, getRedstoneSignalFromContainer, getSlot, getStateId, getType, incrementStateId, initializeContents, isValidQuickcraftType, isValidSlotIndex, moveItemStackTo, removeSlotListener, resetQuickCraft, resumeRemoteUpdates, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotUnsafe, setSelectedBundleItemIndex, setSynchronizer, slotsChanged, stillValid, suppressRemoteUpdates, transferState
-
Constructor Details
-
Method Details
-
getDefinition
-
getPlayer
public net.minecraft.world.entity.player.Player getPlayer() -
getSource
-
getContainer
public net.minecraft.world.Container getContainer()The inventory the slots show: the real one on the server, the synced copy on the client. -
getContainerSlotCount
public int getContainerSlotCount()The number of container slots before the player's inventory slots. -
attachments
The attachments of what the menu is open on: the block entity or the stack. -
get
An attachment of the block entity or stack: on clients, the value the menu synced (if its definition syncs it), or else the one the client has. -
getValue
A value synced withStorageMenuDefinition.Builder.syncValue(String, StreamCodec, T, Function): read on the server, received on clients. -
sendAllDataToRemote
public void sendAllDataToRemote()- Overrides:
sendAllDataToRemotein classnet.minecraft.world.inventory.AbstractContainerMenu
-
broadcastChanges
public void broadcastChanges()- Overrides:
broadcastChangesin classnet.minecraft.world.inventory.AbstractContainerMenu
-
broadcastFullState
public void broadcastFullState()- Overrides:
broadcastFullStatein classnet.minecraft.world.inventory.AbstractContainerMenu
-
receiveValues
public void receiveValues(List<StorageMenuValuesPayload.Entry> entries, net.minecraft.core.RegistryAccess registries) Values from the server. Runs on the client. -
onValuesReceived
protected void onValuesReceived()Called on the client after synced values arrived. -
clickMenuButton
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int buttonId) - Overrides:
clickMenuButtonin classnet.minecraft.world.inventory.AbstractContainerMenu
-
clicked
public void clicked(int slotIndex, int buttonNum, net.minecraft.world.inventory.ContainerInput input, net.minecraft.world.entity.player.Player player) - Overrides:
clickedin classnet.minecraft.world.inventory.AbstractContainerMenu
-
quickMoveStack
public net.minecraft.world.item.ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slotIndex) - Specified by:
quickMoveStackin classnet.minecraft.world.inventory.AbstractContainerMenu
-
stillValid
public boolean stillValid(net.minecraft.world.entity.player.Player player) - Specified by:
stillValidin classnet.minecraft.world.inventory.AbstractContainerMenu
-
removed
public void removed(net.minecraft.world.entity.player.Player player) - Overrides:
removedin classnet.minecraft.world.inventory.AbstractContainerMenu
-