Class MenuRegistry
java.lang.Object
me.shedaniel.architectury.registry.MenuRegistry
A utility class to register
MenuType
s and Screen
s for containers-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
MenuRegistry.ExtendedMenuTypeFactory<T extends net.minecraft.world.inventory.AbstractContainerMenu>
Creates extended menus.static interface
MenuRegistry.ScreenFactory<H extends net.minecraft.world.inventory.AbstractContainerMenu,
S extends net.minecraft.client.gui.screens.Screen & net.minecraft.client.gui.screens.inventory.MenuAccess<H>> Creates new screens.static interface
MenuRegistry.SimpleMenuTypeFactory<T extends net.minecraft.world.inventory.AbstractContainerMenu>
Creates simple menus. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends net.minecraft.world.inventory.AbstractContainerMenu>
net.minecraft.world.inventory.MenuType<T>of
(MenuRegistry.SimpleMenuTypeFactory<T> factory) Creates a simpleMenuType
.static <T extends net.minecraft.world.inventory.AbstractContainerMenu>
net.minecraft.world.inventory.MenuType<T>ofExtended
(MenuRegistry.ExtendedMenuTypeFactory<T> factory) Creates a extendedMenuType
.static void
openExtendedMenu
(net.minecraft.server.level.ServerPlayer player, ExtendedMenuProvider provider) Opens the menu.static void
openExtendedMenu
(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> bufWriter) Opens the menu.static void
openMenu
(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider) Opens the menu.static <H extends net.minecraft.world.inventory.AbstractContainerMenu,
S extends net.minecraft.client.gui.screens.Screen & net.minecraft.client.gui.screens.inventory.MenuAccess<H>>
voidregisterScreenFactory
(net.minecraft.world.inventory.MenuType<? extends H> type, MenuRegistry.ScreenFactory<H, S> factory) Registers a Screen Factory on the client to display.
-
Method Details
-
openExtendedMenu
public static void openExtendedMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider, Consumer<net.minecraft.network.FriendlyByteBuf> bufWriter) Opens the menu.- Parameters:
player
- The player affectedprovider
- TheMenuProvider
that provides the menubufWriter
- That writer that sends extra data forMenuType
created withofExtended(ExtendedMenuTypeFactory)
-
openMenu
public static void openMenu(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.MenuProvider provider) Opens the menu.- Parameters:
player
- The player affectedprovider
- TheMenuProvider
that provides the menu
-
of
public static <T extends net.minecraft.world.inventory.AbstractContainerMenu> net.minecraft.world.inventory.MenuType<T> of(MenuRegistry.SimpleMenuTypeFactory<T> factory) Creates a simpleMenuType
.- Type Parameters:
T
- The type ofAbstractContainerMenu
that handles the logic for theMenuType
- Parameters:
factory
- A functional interface to create theMenuType
from an id (Integer) and inventory- Returns:
- The
MenuType
for yourAbstractContainerMenu
-
ofExtended
public static <T extends net.minecraft.world.inventory.AbstractContainerMenu> net.minecraft.world.inventory.MenuType<T> ofExtended(MenuRegistry.ExtendedMenuTypeFactory<T> factory) Creates a extendedMenuType
.- Type Parameters:
T
- The type ofAbstractContainerMenu
that handles the logic for theMenuType
- Parameters:
factory
- A functional interface to create theMenuType
from an id (Integer),Inventory
, andFriendlyByteBuf
- Returns:
- The
MenuType
for yourAbstractContainerMenu
-
registerScreenFactory
@Environment(CLIENT) public static <H extends net.minecraft.world.inventory.AbstractContainerMenu,S extends net.minecraft.client.gui.screens.Screen & net.minecraft.client.gui.screens.inventory.MenuAccess<H>> void registerScreenFactory(net.minecraft.world.inventory.MenuType<? extends H> type, MenuRegistry.ScreenFactory<H, S> factory) Registers a Screen Factory on the client to display.- Type Parameters:
H
- The type ofAbstractContainerMenu
for the screenS
- The type for theScreen
- Parameters:
type
- TheMenuType
the screen visualizesfactory
- A functional interface that is used to create newScreen
s
-