ScreenHandlerRegistry

public final class ScreenHandlerRegistry

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 handlersSimple 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
{@code * // Creating the screen handler type * public static final ScreenHandlerTypeOVEN = 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

Types

ExtendedClientHandlerFactory
Link copied to clipboard
public interface ExtendedClientHandlerFactory<T extends ScreenHandler>
A factory for client-sided screen handler instanceswith additional screen opening data.
SimpleClientHandlerFactory
Link copied to clipboard
public interface SimpleClientHandlerFactory<T extends ScreenHandler>
A factory for client-sided screen handler instances.

Functions

registerExtended
Link copied to clipboard
static ScreenHandlerType<TregisterExtended<T extends ScreenHandler>(Identifier id, ScreenHandlerRegistry.ExtendedClientHandlerFactory<T> factory)
Creates and registers a new {@code ScreenHandlerType} that creates client-sided screen handlers with additionalnetworked opening data.
registerSimple
Link copied to clipboard
static ScreenHandlerType<TregisterSimple<T extends ScreenHandler>(Identifier id, ScreenHandlerRegistry.SimpleClientHandlerFactory<T> factory)
Creates and registers a new {@code ScreenHandlerType} that creates client-sided screen handlers using the factory.

Sources

jvm source
Link copied to clipboard