Package org.moddingx.libx.menu
Class MenuBase
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
org.moddingx.libx.menu.MenuBase
- Direct Known Subclasses:
DefaultMenu
,GenericMenu
public abstract class MenuBase
extends net.minecraft.world.inventory.AbstractContainerMenu
A base class for
menus
. Provides some utilities that are useful for any type
of menu. When using this it's important to register the player inventory slots through
layoutPlayerInventorySlots(int, int)
and after all the other slots.-
Field Summary
Fields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, containerId, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, slots
-
Constructor Summary
ModifierConstructorDescriptionprotected
MenuBase
(net.minecraft.world.inventory.MenuType<?> type, int id, net.minecraft.world.entity.player.Inventory inventory) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
addSlotBox
(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy) Adds a box of slots to the containerprotected int
addSlotBox
(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy, com.mojang.datafixers.util.Function4<net.minecraftforge.items.IItemHandler, Integer, Integer, Integer, net.minecraft.world.inventory.Slot> slotFactory) Adds a box of slots to the containerprotected int
addSlotRange
(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int amount, int dx) Adds a row of slots to the containerprotected int
addSlotRange
(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int amount, int dx, com.mojang.datafixers.util.Function4<net.minecraftforge.items.IItemHandler, Integer, Integer, Integer, net.minecraft.world.inventory.Slot> slotFactory) Adds a row of slots to the containerprotected void
layoutPlayerInventorySlots
(int leftCol, int topRow) Places the player inventory slots into the container.protected boolean
moveItemStackTo
(net.minecraft.world.item.ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) 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, quickMoveStack, removed, removeSlotListener, resetQuickCraft, resumeRemoteUpdates, sendAllDataToRemote, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotNoCopy, setSynchronizer, slotsChanged, stillValid, stillValid, suppressRemoteUpdates, transferState
-
Field Details
-
playerInventory
public final net.minecraftforge.items.IItemHandler playerInventory
-
-
Constructor Details
-
MenuBase
protected MenuBase(@Nullable net.minecraft.world.inventory.MenuType<?> type, int id, net.minecraft.world.entity.player.Inventory inventory)
-
-
Method Details
-
layoutPlayerInventorySlots
protected void layoutPlayerInventorySlots(int leftCol, int topRow) Places the player inventory slots into the container.- Parameters:
leftCol
- The x coordinate of the top left slottopRow
- The y coordinate of the top left slot
-
addSlotBox
protected int addSlotBox(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy) Adds a box of slots to the container- Parameters:
handler
- The inventory of the slotindex
- The index of the first slotx
- The x coordinate of the top left sloty
- The y coordinate of the top left slothorAmount
- The amount of slots in horizontal directiondx
- The space between two slots in horizontal direction. Should not be less than 16 or you create overlapping slots. Most of the time this is 18verAmount
- The amount of slots in vertical directiondy
- The space between two slots in vertical direction. Should not be less than 16 or you create overlapping slots. Most of the time this is 18- Returns:
- The next index to be used to create a slot
-
addSlotRange
protected int addSlotRange(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int amount, int dx) Adds a row of slots to the container- Parameters:
handler
- The inventory of the slotindex
- The index of the first slotx
- The x coordinate of the top left sloty
- The y coordinate of the top left slotamount
- The amount of slotsdx
- The space between two slots. Should not be less than 16 or you create overlapping slots. Most of the time this is 18- Returns:
- The next index to be used to create a slot
-
addSlotBox
protected int addSlotBox(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy, com.mojang.datafixers.util.Function4<net.minecraftforge.items.IItemHandler, Integer, Integer, Integer, net.minecraft.world.inventory.Slot> slotFactory) Adds a box of slots to the container- Parameters:
handler
- The inventory of the slotindex
- The index of the first slotx
- The x coordinate of the top left sloty
- The y coordinate of the top left slothorAmount
- The amount of slots in horizontal directiondx
- The space between two slots in horizontal direction. Should not be less than 16 or you create overlapping slots. Most of the time this is 18verAmount
- The amount of slots in vertical directiondy
- The space between two slots in vertical direction. Should not be less than 16 or you create overlapping slots. Most of the time this is 18slotFactory
- A factory to create a slot. This could beSlotItemHandler::new
orSlotOutputOnly::new
for output slots.- Returns:
- The next index to be used to create a slot
-
addSlotRange
protected int addSlotRange(net.minecraftforge.items.IItemHandler handler, int index, int x, int y, int amount, int dx, com.mojang.datafixers.util.Function4<net.minecraftforge.items.IItemHandler, Integer, Integer, Integer, net.minecraft.world.inventory.Slot> slotFactory) Adds a row of slots to the container- Parameters:
handler
- The inventory of the slotindex
- The index of the first slotx
- The x coordinate of the top left sloty
- The y coordinate of the top left slotamount
- The amount of slotsdx
- The space between two slots. Should not be less than 16 or you create overlapping slots. Most of the time this is 18slotFactory
- A factory to create a slot. This could beSlotItemHandler::new
orSlotOutputOnly::new
for output slots.- Returns:
- The next index to be used to create a slot
-
moveItemStackTo
protected boolean moveItemStackTo(@Nonnull net.minecraft.world.item.ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) - Overrides:
moveItemStackTo
in classnet.minecraft.world.inventory.AbstractContainerMenu
-