Class ScreenRegistry
java.lang.Object
net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry
An API for registering handled screens that represent screen handlers on the client.
Exposes vanilla's private
HandledScreens.register()
to modders as ScreenRegistry.register()
.
Example
// In a client-side initialization method:
ScreenRegistry.register(MyScreenHandlers.OVEN, OvenScreen::new);
// Screen class
public class OvenScreen extends HandledScreen<OvenScreenHandler> {
public OvenScreen(OvenScreenHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
}
}
- See Also:
registering screen handlers
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
ScreenRegistry.Factory<H extends net.minecraft.screen.ScreenHandler,S extends net.minecraft.client.gui.screen.Screen & net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider<H>>
A factory for handled screens. -
Method Summary
Modifier and TypeMethodDescriptionstatic <H extends net.minecraft.screen.ScreenHandler, S extends net.minecraft.client.gui.screen.Screen & net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider<H>>
voidregister(net.minecraft.screen.ScreenHandlerType<? extends H> type, ScreenRegistry.Factory<H,S> screenFactory)
Registers a new screen factory for a screen handler type.
-
Method Details
-
register
public static <H extends net.minecraft.screen.ScreenHandler, S extends net.minecraft.client.gui.screen.Screen & net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider<H>> void register(net.minecraft.screen.ScreenHandlerType<? extends H> type, ScreenRegistry.Factory<H,S> screenFactory)Registers a new screen factory for a screen handler type.- Type Parameters:
H
- the screen handler typeS
- the screen type- Parameters:
type
- the screen handler type objectscreenFactory
- the screen handler factory
-