Class ScreenHandlerRegistry

java.lang.Object
net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry

@Deprecated public final class ScreenHandlerRegistry extends Object
Deprecated.
Replaced by
An API for creating and registering screen handler types.

This class exposes the private ScreenHandlerType constructor, as well as adds support for creating types using Fabric's extended screen handler API.

Screen handlers types are used to synchronize screen handlers between the server and the client. Screen handlers manage the items and integer properties that are needed to show on screens, such as the items in a chest or the progress of a furnace.

Simple and extended screen handlers

Simple screen handlers are the type of screen handlers used in vanilla. They can automatically synchronize items and integer properties between the server and the client, but they don't support having custom data sent in the opening packet.

This module adds extended screen handlers that can synchronize their own custom data when they are opened, which can be useful for defining additional properties of a screen on the server. For example, a mod can synchronize text that will show up as a label.

Example

 
 // Creating the screen handler type
 public static final ScreenHandlerType<OvenScreenHandler> OVEN = ScreenHandlerRegistry.registerSimple(new Identifier("my_mod", "oven"), OvenScreenHandler::new);

 // Screen handler class
 public class OvenScreenHandler extends ScreenHandler {
 	public OvenScreenHandler(int syncId) {
 		super(MyScreenHandlers.OVEN, syncId);
 	}
 }

 // Opening the screen
 NamedScreenHandlerFactory factory = ...;
 player.openHandledScreen(factory); // only works on ServerPlayerEntity instances
 
 
See Also:
  • Method Details