Class ExtendedScreenHandlerType<T extends net.minecraft.screen.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

public class ExtendedScreenHandlerType<T extends net.minecraft.screen.ScreenHandler> extends net.minecraft.screen.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
 
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    ExtendedScreenHandlerType.ExtendedFactory<T extends net.minecraft.screen.ScreenHandler>
    A factory for creating screen handler instances from additional opening data.
  • Field Summary

    Fields inherited from class net.minecraft.screen.ScreenHandlerType

    ANVIL, BEACON, BLAST_FURNACE, BREWING_STAND, CARTOGRAPHY_TABLE, CRAFTING, ENCHANTMENT, FURNACE, GENERIC_3X3, GENERIC_9X1, GENERIC_9X2, GENERIC_9X3, GENERIC_9X4, GENERIC_9X5, GENERIC_9X6, GRINDSTONE, HOPPER, LECTERN, LOOM, MERCHANT, SHULKER_BOX, SMITHING, SMOKER, STONECUTTER
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an extended screen handler type.
  • Method Summary

    Modifier and Type
    Method
    Description
    final T
    create(int syncId, net.minecraft.entity.player.PlayerInventory inventory)
    create(int syncId, net.minecraft.entity.player.PlayerInventory inventory, net.minecraft.network.PacketByteBuf buf)
    Creates a new screen handler using the extra opening data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait