Package info.u_team.u_team_core.menu
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Used as a function to add slotsstatic interface
Used as a function to add slots -
Field Summary
Fields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, containerId, containerListeners, lastSlots, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, slots, stateId, suppressRemoteUpdates
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
UAbstractContainerMenu
(net.minecraft.world.inventory.MenuType<?> menuType, int containerId) Creates a container menu. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
(net.minecraft.world.Container container, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.protected void
addSlots
(net.minecraft.world.Container container, int startIndex, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.protected void
addSlots
(net.minecraft.world.Container container, UAbstractContainerMenu.SlotContainerFunction function, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.protected void
addSlots
(net.minecraft.world.Container container, UAbstractContainerMenu.SlotContainerFunction function, int startIndex, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.protected void
addSlots
(net.minecraftforge.items.IItemHandler handler, int rows, int columns, int x, int y) This methods can add anyIItemHandler
to this menu.protected void
addSlots
(net.minecraftforge.items.IItemHandler handler, int startIndex, int rows, int columns, int x, int y) This methods can add anyIItemHandler
to this menu.protected void
addSlots
(net.minecraftforge.items.IItemHandler handler, UAbstractContainerMenu.SlotHandlerFunction function, int rows, int columns, int x, int y) This methods can add anyIItemHandler
to this menu.protected void
addSlots
(net.minecraftforge.items.IItemHandler handler, UAbstractContainerMenu.SlotHandlerFunction function, int startIndex, int rows, int columns, int x, int y) This methods can add anyIItemHandler
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 thesetSynchronizerPlayer(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, getQuickCraftSlotCount, 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
-
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 typecontainerId
- 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 insideServerPlayer.initMenu(AbstractContainerMenu)
. This method sets player that has the container opened. Will be called beforeAbstractContainerMenu.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 thesetSynchronizerPlayer(ServerPlayer)
.- Parameters:
player
- Server player that openend the container
-
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 inventoryx
- Start xy
- Start y
-
addSlots
protected void addSlots(net.minecraft.world.Container container, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.- Parameters:
container
- Inventory containerrows
- Slot rowscolumns
- Slot columnsx
- Start xy
- Start y
-
addSlots
protected void addSlots(net.minecraft.world.Container container, int startIndex, int rows, int columns, int x, int y) This methods can add anyContainer
to this menu.- Parameters:
container
- Inventory containerstartIndex
- Start index of inventoryrows
- Slot rowscolumns
- Slot columnsx
- Start xy
- Start y
-
addSlots
protected void addSlots(net.minecraftforge.items.IItemHandler handler, int rows, int columns, int x, int y) This methods can add anyIItemHandler
to this menu.- Parameters:
handler
- Item inventory handlerrows
- Slot rowscolumns
- Slot columnsx
- Start xy
- Start y
-
addSlots
protected void addSlots(net.minecraftforge.items.IItemHandler handler, int startIndex, int rows, int columns, int x, int y) This methods can add anyIItemHandler
to this menu.- Parameters:
handler
- Item inventory handlerstartIndex
- Start index of inventoryrows
- Slot rowscolumns
- Slot columnsx
- Start xy
- Start y
-