mirror of
https://github.com/FabricMC/fabric.git
synced 2025-07-28 15:09:35 -04:00
Fix screen handler test mod crashing on dedicated server. (#823)
This commit is contained in:
parent
28a9468044
commit
c10360a765
2 changed files with 3 additions and 2 deletions
fabric-screen-handler-api-v1/src
main/java/net/fabricmc/fabric/api/screenhandler/v1
testmod/java/net/fabricmc/fabric/test/screenhandler
|
@ -81,7 +81,8 @@ public final class ScreenHandlerRegistry {
|
|||
*/
|
||||
public static <T extends ScreenHandler> ScreenHandlerType<T> registerSimple(Identifier id, SimpleClientHandlerFactory<T> factory) {
|
||||
// Wrap our factory in vanilla's factory; it will not be public for users.
|
||||
ScreenHandlerType<T> type = new ScreenHandlerType<>(factory::create);
|
||||
// noinspection Convert2MethodRef - Must be a lambda or else dedicated server will crash
|
||||
ScreenHandlerType<T> type = new ScreenHandlerType<>((syncId, inventory) -> factory.create(syncId, inventory));
|
||||
return Registry.register(Registry.SCREEN_HANDLER, id, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ScreenHandlerTest implements ModInitializer {
|
|||
public static final Item POSITIONED_BAG = new PositionedBagItem(new Item.Settings().group(ItemGroup.TOOLS).maxCount(1));
|
||||
public static final Block BOX = new BoxBlock(AbstractBlock.Settings.copy(Blocks.OAK_WOOD));
|
||||
public static final Item BOX_ITEM = new BlockItem(BOX, new Item.Settings().group(ItemGroup.DECORATIONS));
|
||||
public static final BlockEntityType<?> BOX_ENTITY = BlockEntityType.Builder.create(BoxBlockEntity::new, BOX).build(null);
|
||||
public static final BlockEntityType<BoxBlockEntity> BOX_ENTITY = BlockEntityType.Builder.create(BoxBlockEntity::new, BOX).build(null);
|
||||
public static final ScreenHandlerType<BagScreenHandler> BAG_SCREEN_HANDLER = ScreenHandlerRegistry.registerSimple(id("bag"), BagScreenHandler::new);
|
||||
public static final ScreenHandlerType<PositionedBagScreenHandler> POSITIONED_BAG_SCREEN_HANDLER = ScreenHandlerRegistry.registerExtended(id("positioned_bag"), PositionedBagScreenHandler::new);
|
||||
public static final ScreenHandlerType<BoxScreenHandler> BOX_SCREEN_HANDLER = ScreenHandlerRegistry.registerExtended(id("box"), BoxScreenHandler::new);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue