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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    What 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

    Constructors
    Modifier
    Constructor
    Description
    protected
    StorageMenu(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 Type
    Method
    Description
    The attachments of what the menu is open on: the block entity or the stack.
    void
     
    void
     
    void
    clicked(int slotIndex, int buttonNum, net.minecraft.world.inventory.ContainerInput input, net.minecraft.world.entity.player.Player player)
     
    boolean
    clickMenuButton(net.minecraft.world.entity.player.Player player, int buttonId)
     
    <T> T
    get(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.Container
    The inventory the slots show: the real one on the server, the synced copy on the client.
    int
    The number of container slots before the player's inventory slots.
     
    net.minecraft.world.entity.player.Player
     
     
    <T> T
    getValue(String name, T defaultValue)
    A value synced with StorageMenuDefinition.Builder.syncValue(String, StreamCodec, T, Function): read on the server, received on clients.
    protected void
    Called on the client after synced values arrived.
    net.minecraft.world.item.ItemStack
    quickMoveStack(net.minecraft.world.entity.player.Player player, int slotIndex)
     
    void
    receiveValues(List<StorageMenuValuesPayload.Entry> entries, net.minecraft.core.RegistryAccess registries)
    Values from the server.
    void
    removed(net.minecraft.world.entity.player.Player player)
     
    void
     
    boolean
    stillValid(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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StorageMenu

      protected StorageMenu(StorageMenuDefinition definition, int containerId, net.minecraft.world.entity.player.Inventory inventory, StorageMenu.Source source, net.minecraft.world.Container container, @Nullable @Nullable net.minecraft.world.Container opened)
  • Method Details

    • getDefinition

      public StorageMenuDefinition getDefinition()
    • getPlayer

      public net.minecraft.world.entity.player.Player getPlayer()
    • getSource

      public StorageMenu.Source 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

      public AttachmentHolder attachments()
      The attachments of what the menu is open on: the block entity or the stack.
    • get

      public <T> T get(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.
    • getValue

      public <T> T getValue(String name, T defaultValue)
      A value synced with StorageMenuDefinition.Builder.syncValue(String, StreamCodec, T, Function): read on the server, received on clients.
    • sendAllDataToRemote

      public void sendAllDataToRemote()
      Overrides:
      sendAllDataToRemote in class net.minecraft.world.inventory.AbstractContainerMenu
    • broadcastChanges

      public void broadcastChanges()
      Overrides:
      broadcastChanges in class net.minecraft.world.inventory.AbstractContainerMenu
    • broadcastFullState

      public void broadcastFullState()
      Overrides:
      broadcastFullState in class net.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:
      clickMenuButton in class net.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:
      clicked in class net.minecraft.world.inventory.AbstractContainerMenu
    • quickMoveStack

      public net.minecraft.world.item.ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slotIndex)
      Specified by:
      quickMoveStack in class net.minecraft.world.inventory.AbstractContainerMenu
    • stillValid

      public boolean stillValid(net.minecraft.world.entity.player.Player player)
      Specified by:
      stillValid in class net.minecraft.world.inventory.AbstractContainerMenu
    • removed

      public void removed(net.minecraft.world.entity.player.Player player)
      Overrides:
      removed in class net.minecraft.world.inventory.AbstractContainerMenu