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
Modifier and TypeClassDescriptionstatic 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
ConstructorDescriptionConstructs an extended screen handler type. -
Method Summary
Modifier and TypeMethodDescriptionfinal T
create
(int syncId, net.minecraft.entity.player.PlayerInventory inventory) Deprecated.create
(int syncId, net.minecraft.entity.player.PlayerInventory inventory, net.minecraft.network.PacketByteBuf buf) Creates a new screen handler using the extra opening data.
-
Constructor Details
-
ExtendedScreenHandlerType
Constructs an extended screen handler type.- Parameters:
factory
- the screen handler factory used forcreate(int, PlayerInventory, PacketByteBuf)
-
-
Method Details
-
create
@Deprecated public final T create(int syncId, net.minecraft.entity.player.PlayerInventory inventory) Deprecated.Usecreate(int, PlayerInventory, PacketByteBuf)
instead.- Overrides:
create
in classnet.minecraft.screen.ScreenHandlerType<T extends net.minecraft.screen.ScreenHandler>
- Throws:
UnsupportedOperationException
- always; usecreate(int, PlayerInventory, PacketByteBuf)
-
create
public T create(int syncId, net.minecraft.entity.player.PlayerInventory inventory, net.minecraft.network.PacketByteBuf buf) Creates a new screen handler using the extra opening data.- Parameters:
syncId
- the sync IDinventory
- the player inventorybuf
- the buffer containing the synced opening data- Returns:
- the created screen handler
-
create(int, PlayerInventory, PacketByteBuf)
instead.