Class ExtendedScreenHandlerType<T extends ScreenHandler>

java.lang.Object
net.minecraft.screen.ScreenHandlerType<T>
net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType<T>
Type Parameters:
T - the type of screen handler created by this type
All Implemented Interfaces:
ToggleableFeature

public class ExtendedScreenHandlerType<T extends ScreenHandler> extends ScreenHandlerType<T>
A ScreenHandlerType for an extended screen handler that synchronizes additional data to the client when it is opened.

Extended screen handlers can be opened using PlayerEntity.openHandledScreen with an ExtendedScreenHandlerFactory.

Example

 
 // Creating and registering the type
 public static final ExtendedScreenHandlerType<OvenScreenHandler> OVEN =
 	new ExtendedScreenHandlerType((syncId, inventory, buf) -> ...);
 Registry.register(Registry.SCREEN_HANDLER, new Identifier(...), OVEN);

 // Note: remember to also register the screen using vanilla's HandledScreens!

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

 // Opening the extended screen handler
 var factory = new ExtendedScreenHandlerFactory() {
 	...
 };
 player.openHandlerScreen(factory); // only works on ServerPlayerEntity instances