Class UAbstractContainerMenu

java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
info.u_team.u_team_core.menu.UAbstractContainerMenu
Direct Known Subclasses:
FluidContainerMenu

public abstract class UAbstractContainerMenu extends net.minecraft.world.inventory.AbstractContainerMenu
Enhanced version of AbstractContainerMenu with the benefit that the player that opened the container is known and a method is called when the container is opened on the logical server. Furthermore adds some convenience methods to add multiple slots.
  • Field Summary

    Fields inherited from class net.minecraft.world.inventory.AbstractContainerMenu

    CARRIED_SLOT_SIZE, containerId, lastSlots, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, slots
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    UAbstractContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId)
    Creates a container menu.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addPlayerInventory(net.minecraft.world.entity.player.Inventory playerInventory, int x, int y)
    This methods adds a player inventory to the container.
    protected void
    addSlots(ItemSlotCreator slotCreator, int rows, int columns, int x, int y)
    This methods can add any ItemSlotCreator to this menu.
    protected void
    addSlots(ItemSlotCreator slotCreator, int startIndex, int rows, int columns, int x, int y)
    This methods can add any ItemSlotCreator to this menu.
    protected List<net.minecraft.world.item.ItemStack>
    Returns the last slot list that is used to check if a stack has changed since last check.
    final net.minecraft.server.level.ServerPlayer
    Returns the player that opened the container and should be used for synchronizing purposes.
    void
    initMenu(net.minecraft.server.level.ServerPlayer player)
    Will be called immediately after the setSynchronizerPlayer(ServerPlayer).
    final void
    setSynchronizerPlayer(net.minecraft.server.level.ServerPlayer player)
    Do not call your self.

    Methods inherited from class net.minecraft.world.inventory.AbstractContainerMenu

    addDataSlot, addDataSlots, addSlot, addSlotListener, broadcastChanges, broadcastFullState, canDragTo, canItemQuickReplace, canTakeItemForPickAll, checkContainerDataCount, checkContainerSize, clearContainer, clicked, clickMenuButton, findSlot, getCarried, getItems, getQuickcraftHeader, getQuickcraftMask, getQuickCraftPlaceCount, getQuickcraftType, getRedstoneSignalFromBlockEntity, getRedstoneSignalFromContainer, getSlot, getStateId, getType, incrementStateId, initializeContents, isValidQuickcraftType, isValidSlotIndex, moveItemStackTo, quickMoveStack, removed, removeSlotListener, resetQuickCraft, resumeRemoteUpdates, sendAllDataToRemote, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotNoCopy, setSynchronizer, slotsChanged, stillValid, stillValid, suppressRemoteUpdates, transferState

    Methods inherited from class java.lang.Object

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

    • UAbstractContainerMenu

      protected UAbstractContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId)
      Creates a container menu. Must be implemented by a sub class to be used.
      Parameters:
      menuType - Menu type
      containerId - Container id
  • Method Details

    • setSynchronizerPlayer

      public final void setSynchronizerPlayer(net.minecraft.server.level.ServerPlayer player)
      Do not call your self. Will be called from an asm hook inside ServerPlayer.initMenu(AbstractContainerMenu). This method sets player that has the container opened. Will be called before AbstractContainerMenu.setSynchronizer(net.minecraft.world.inventory.ContainerSynchronizer) so that method can be used for synchronizing already.
      Parameters:
      player - Server player that opened the container
    • getSynchronizerPlayer

      public final net.minecraft.server.level.ServerPlayer getSynchronizerPlayer()
      Returns the player that opened the container and should be used for synchronizing purposes.
      Returns:
      Server player that opened the container
    • initMenu

      public void initMenu(net.minecraft.server.level.ServerPlayer player)
      Will be called immediately after the setSynchronizerPlayer(ServerPlayer).
      Parameters:
      player - Server player that opened the container
    • getLastSlots

      protected List<net.minecraft.world.item.ItemStack> getLastSlots()
      Returns the last slot list that is used to check if a stack has changed since last check. The list should not be modified manually.
      Returns:
      List with item stacks
    • addPlayerInventory

      protected void addPlayerInventory(net.minecraft.world.entity.player.Inventory playerInventory, int x, int y)
      This methods adds a player inventory to the container.
      Parameters:
      playerInventory - Player inventory
      x - Start x
      y - Start y
    • addSlots

      protected void addSlots(ItemSlotCreator slotCreator, int rows, int columns, int x, int y)
      This methods can add any ItemSlotCreator to this menu.
      Parameters:
      slotCreator - Slot creator
      rows - Slot rows
      columns - Slot columns
      x - Start x
      y - Start y
    • addSlots

      protected void addSlots(ItemSlotCreator slotCreator, int startIndex, int rows, int columns, int x, int y)
      This methods can add any ItemSlotCreator to this menu.
      Parameters:
      slotCreator - Slot creator
      startIndex - Start index of inventory
      rows - Slot rows
      columns - Slot columns
      x - Start x
      y - Start y