Package net.fabricmc.fabric.api.screenhandler.v1

package net.fabricmc.fabric.api.screenhandler.v1
The Fabric screen handler API for creating screen handlers and screen handler types.

Screen handlers types are used to synchronize screen handlers between the server and the client. Their main job is to create screen handler instances on 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. You can create simple screen handlers using vanilla's ScreenHandlerType.

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. You can create extended screen handlers using ExtendedScreenHandlerType.

Opening screen handlers

Screen handlers can be opened using PlayerEntity.openHandledScreen(net.minecraft.screen.NamedScreenHandlerFactory). Note that calling it on the logical client does nothing. To open an extended screen handler, the factory passed in should be an ExtendedScreenHandlerFactory.