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
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
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, LEGACY_SMITHING, LOOM, MERCHANT, SHULKER_BOX, SMITHING, SMOKER, STONECUTTER
Fields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS
-
Constructor Summary
ConstructorDescriptionConstructs an extended screen handler type. -
Method Summary
Modifier and TypeMethodDescriptionfinal T
create
(int syncId, PlayerInventory inventory) Deprecated.create
(int syncId, PlayerInventory inventory, PacketByteBuf buf) Creates a new screen handler using the extra opening data.Methods inherited from class net.minecraft.screen.ScreenHandlerType
getRequiredFeatures
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Constructor Details
-
ExtendedScreenHandlerType
Constructs an extended screen handler type.- Parameters:
factory
- the screen handler factory used forcreate(int, PlayerInventory, PacketByteBuf)
-
-
Method Details
-
create
Deprecated.Usecreate(int, PlayerInventory, PacketByteBuf)
instead.- Overrides:
create
in classScreenHandlerType<T extends ScreenHandler>
- Throws:
UnsupportedOperationException
- always; usecreate(int, PlayerInventory, PacketByteBuf)
-
create
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.