From 71cc66940abc8cd4849daa811a95b220de8a2e0e Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Tue, 17 Dec 2024 15:15:28 +0100 Subject: [PATCH] Add a method to build menu types without causing them to be registered. --- .../appeng/menu/implementations/MenuTypeBuilder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/appeng/menu/implementations/MenuTypeBuilder.java b/src/main/java/appeng/menu/implementations/MenuTypeBuilder.java index 25c775b8bcf..66188d34d96 100644 --- a/src/main/java/appeng/menu/implementations/MenuTypeBuilder.java +++ b/src/main/java/appeng/menu/implementations/MenuTypeBuilder.java @@ -188,7 +188,7 @@ public MenuType build(String id) { /** * Creates a menu type that uses this helper as a factory and network deserializer. */ - public MenuType build(ResourceLocation id) { + public MenuType buildUnregistered(ResourceLocation id) { Preconditions.checkState(menuType == null, "build was already called"); Preconditions.checkState(this.id == null, "id should not be set"); @@ -199,6 +199,16 @@ public MenuType build(ResourceLocation id) { return menuType; } + /** + * Creates a menu type that uses this helper as a factory and network deserializer, and queues it for registration + * with Vanilla. + */ + public MenuType build(ResourceLocation id) { + var menuType = buildUnregistered(id); + InitMenuTypes.queueRegistration(this.id, menuType); + return menuType; + } + @FunctionalInterface public interface MenuFactory { C create(int containerId, Inventory playerInv, I menuHost);