diff --git a/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java b/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java index c5820a73..dbe37b4b 100644 --- a/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java +++ b/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java @@ -25,6 +25,8 @@ import appeng.init.client.InitScreens; import appeng.items.storage.BasicStorageCell; import appeng.items.tools.powered.PortableCellItem; +import appeng.menu.implementations.InterfaceMenu; +import appeng.menu.implementations.PatternProviderMenu; import gripe._90.megacells.MEGACells; import gripe._90.megacells.block.MEGACraftingUnitType; @@ -37,8 +39,6 @@ import gripe._90.megacells.definition.MEGAItems; import gripe._90.megacells.definition.MEGAMenus; import gripe._90.megacells.item.cell.PortableCellWorkbenchTooltipComponent; -import gripe._90.megacells.menu.MEGAInterfaceMenu; -import gripe._90.megacells.menu.MEGAPatternProviderMenu; @Mod(value = MEGACells.MODID, dist = Dist.CLIENT) public class MEGACellsClient { @@ -55,12 +55,12 @@ private static void initScreens(RegisterMenuScreensEvent event) { InitScreens.register( event, MEGAMenus.MEGA_INTERFACE.get(), - InterfaceScreen::new, + InterfaceScreen::new, "/screens/megacells/mega_interface.json"); InitScreens.register( event, MEGAMenus.MEGA_PATTERN_PROVIDER.get(), - PatternProviderScreen::new, + PatternProviderScreen::new, "/screens/megacells/mega_pattern_provider.json"); InitScreens.register( event, MEGAMenus.CELL_DOCK.get(), CellDockScreen::new, "/screens/megacells/cell_dock.json"); diff --git a/src/main/java/gripe/_90/megacells/definition/MEGAMenus.java b/src/main/java/gripe/_90/megacells/definition/MEGAMenus.java index 39c2a290..c23395bd 100644 --- a/src/main/java/gripe/_90/megacells/definition/MEGAMenus.java +++ b/src/main/java/gripe/_90/megacells/definition/MEGAMenus.java @@ -9,23 +9,24 @@ import appeng.helpers.InterfaceLogicHost; import appeng.helpers.patternprovider.PatternProviderLogicHost; import appeng.menu.AEBaseMenu; +import appeng.menu.implementations.InterfaceMenu; import appeng.menu.implementations.MenuTypeBuilder; +import appeng.menu.implementations.PatternProviderMenu; import gripe._90.megacells.MEGACells; import gripe._90.megacells.item.cell.PortableCellWorkbenchMenuHost; import gripe._90.megacells.item.part.CellDockPart; import gripe._90.megacells.menu.CellDockMenu; -import gripe._90.megacells.menu.MEGAInterfaceMenu; -import gripe._90.megacells.menu.MEGAPatternProviderMenu; import gripe._90.megacells.menu.PortableCellWorkbenchMenu; +import gripe._90.megacells.mixin.PatternProviderMenuAccessor; public final class MEGAMenus { public static final DeferredRegister> DR = DeferredRegister.create(Registries.MENU, MEGACells.MODID); - public static final Supplier> MEGA_INTERFACE = - create("mega_interface", MEGAInterfaceMenu::new, InterfaceLogicHost.class); - public static final Supplier> MEGA_PATTERN_PROVIDER = - create("mega_pattern_provider", MEGAPatternProviderMenu::new, PatternProviderLogicHost.class); + public static final Supplier> MEGA_INTERFACE = + createTyped("mega_interface", InterfaceMenu::new, InterfaceLogicHost.class); + public static final Supplier> MEGA_PATTERN_PROVIDER = + createTyped("mega_pattern_provider", PatternProviderMenuAccessor::create, PatternProviderLogicHost.class); public static final Supplier> CELL_DOCK = create("cell_dock", CellDockMenu::new, CellDockPart.class); @@ -36,4 +37,9 @@ private static Supplier> create( String id, MenuTypeBuilder.MenuFactory factory, Class host) { return DR.register(id, () -> MenuTypeBuilder.create(factory, host).build(MEGACells.makeId(id))); } + + private static Supplier> createTyped( + String id, MenuTypeBuilder.TypedMenuFactory factory, Class host) { + return DR.register(id, () -> MenuTypeBuilder.create(factory, host).build(MEGACells.makeId(id))); + } } diff --git a/src/main/java/gripe/_90/megacells/menu/MEGAInterfaceMenu.java b/src/main/java/gripe/_90/megacells/menu/MEGAInterfaceMenu.java deleted file mode 100644 index 27822ae2..00000000 --- a/src/main/java/gripe/_90/megacells/menu/MEGAInterfaceMenu.java +++ /dev/null @@ -1,14 +0,0 @@ -package gripe._90.megacells.menu; - -import net.minecraft.world.entity.player.Inventory; - -import appeng.helpers.InterfaceLogicHost; -import appeng.menu.implementations.InterfaceMenu; - -import gripe._90.megacells.definition.MEGAMenus; - -public class MEGAInterfaceMenu extends InterfaceMenu { - public MEGAInterfaceMenu(int id, Inventory ip, InterfaceLogicHost host) { - super(MEGAMenus.MEGA_INTERFACE.get(), id, ip, host); - } -} diff --git a/src/main/java/gripe/_90/megacells/menu/MEGAPatternProviderMenu.java b/src/main/java/gripe/_90/megacells/menu/MEGAPatternProviderMenu.java deleted file mode 100644 index 6af421e5..00000000 --- a/src/main/java/gripe/_90/megacells/menu/MEGAPatternProviderMenu.java +++ /dev/null @@ -1,14 +0,0 @@ -package gripe._90.megacells.menu; - -import net.minecraft.world.entity.player.Inventory; - -import appeng.helpers.patternprovider.PatternProviderLogicHost; -import appeng.menu.implementations.PatternProviderMenu; - -import gripe._90.megacells.definition.MEGAMenus; - -public class MEGAPatternProviderMenu extends PatternProviderMenu { - public MEGAPatternProviderMenu(int id, Inventory playerInventory, PatternProviderLogicHost host) { - super(MEGAMenus.MEGA_PATTERN_PROVIDER.get(), id, playerInventory, host); - } -} diff --git a/src/main/java/gripe/_90/megacells/mixin/PatternProviderMenuAccessor.java b/src/main/java/gripe/_90/megacells/mixin/PatternProviderMenuAccessor.java new file mode 100644 index 00000000..8696a358 --- /dev/null +++ b/src/main/java/gripe/_90/megacells/mixin/PatternProviderMenuAccessor.java @@ -0,0 +1,20 @@ +package gripe._90.megacells.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.MenuType; + +import appeng.helpers.patternprovider.PatternProviderLogicHost; +import appeng.menu.implementations.PatternProviderMenu; + +// TODO: Remove that pointless extra constructor from upstream AE2 so that this can also go +@Mixin(PatternProviderMenu.class) +public interface PatternProviderMenuAccessor { + @Invoker(value = "") + static PatternProviderMenu create( + MenuType menuType, int id, Inventory ip, PatternProviderLogicHost host) { + throw new AssertionError(); + } +} diff --git a/src/main/resources/assets/ae2/screens/megacells/mega_interface.json b/src/main/resources/assets/ae2/screens/megacells/mega_interface.json index 242052df..91f26916 100644 --- a/src/main/resources/assets/ae2/screens/megacells/mega_interface.json +++ b/src/main/resources/assets/ae2/screens/megacells/mega_interface.json @@ -2,7 +2,7 @@ "includes": ["../common/common.json", "../common/player_inventory.json"], "background": { "texture": "guis/megacells/mega_interface.png", - "srcRect": [0, 0, 176, 238] + "srcRect": [0, 0, 176, 240] }, "slots": { "CONFIG": { @@ -47,8 +47,8 @@ }, "widgets": { "openPriority": { - "left": 154, - "top": 0, + "left": 152, + "top": -5, "width": 16, "height": 16 }, diff --git a/src/main/resources/assets/ae2/screens/megacells/mega_pattern_provider.json b/src/main/resources/assets/ae2/screens/megacells/mega_pattern_provider.json index a6bef0e7..4502ec25 100644 --- a/src/main/resources/assets/ae2/screens/megacells/mega_pattern_provider.json +++ b/src/main/resources/assets/ae2/screens/megacells/mega_pattern_provider.json @@ -2,7 +2,7 @@ "includes": ["../common/common.json", "../common/player_inventory.json"], "background": { "texture": "guis/megacells/mega_pattern_provider.png", - "srcRect": [0, 0, 176, 213] + "srcRect": [0, 0, 176, 215] }, "slots": { "ENCODED_PATTERN": { @@ -47,8 +47,10 @@ }, "widgets": { "openPriority": { - "left": 154, - "top": 0 + "left": 152, + "top": -5, + "width": 20, + "height": 20 }, "lockReason": { "left": 5, diff --git a/src/main/resources/megacells.mixins.json b/src/main/resources/megacells.mixins.json index 7532a5e1..1d869cee 100644 --- a/src/main/resources/megacells.mixins.json +++ b/src/main/resources/megacells.mixins.json @@ -2,7 +2,11 @@ "required": true, "minVersion": "0.8.5", "package": "gripe._90.megacells.mixin", - "mixins": ["ItemEntityMixin", "ItemMenuHostMixin"], + "mixins": [ + "ItemEntityMixin", + "ItemMenuHostMixin", + "PatternProviderMenuAccessor" + ], "client": ["client.BuiltInModelHooksAccessor", "client.ModelBakeryMixin"], "injectors": { "defaultRequire": 1