Skip to content

Commit

Permalink
Remove redundant menu subclasses and fix inconsistent layout for MEGA…
Browse files Browse the repository at this point in the history
… Interface and Pattern Provider
  • Loading branch information
62832 committed Nov 17, 2024
1 parent 5db63b4 commit d536180
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/main/java/gripe/_90/megacells/client/MEGACellsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -55,12 +55,12 @@ private static void initScreens(RegisterMenuScreensEvent event) {
InitScreens.register(
event,
MEGAMenus.MEGA_INTERFACE.get(),
InterfaceScreen<MEGAInterfaceMenu>::new,
InterfaceScreen<InterfaceMenu>::new,
"/screens/megacells/mega_interface.json");
InitScreens.register(
event,
MEGAMenus.MEGA_PATTERN_PROVIDER.get(),
PatternProviderScreen<MEGAPatternProviderMenu>::new,
PatternProviderScreen<PatternProviderMenu>::new,
"/screens/megacells/mega_pattern_provider.json");
InitScreens.register(
event, MEGAMenus.CELL_DOCK.get(), CellDockScreen::new, "/screens/megacells/cell_dock.json");
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/gripe/_90/megacells/definition/MEGAMenus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<MenuType<?>> DR = DeferredRegister.create(Registries.MENU, MEGACells.MODID);

public static final Supplier<MenuType<MEGAInterfaceMenu>> MEGA_INTERFACE =
create("mega_interface", MEGAInterfaceMenu::new, InterfaceLogicHost.class);
public static final Supplier<MenuType<MEGAPatternProviderMenu>> MEGA_PATTERN_PROVIDER =
create("mega_pattern_provider", MEGAPatternProviderMenu::new, PatternProviderLogicHost.class);
public static final Supplier<MenuType<InterfaceMenu>> MEGA_INTERFACE =
createTyped("mega_interface", InterfaceMenu::new, InterfaceLogicHost.class);
public static final Supplier<MenuType<PatternProviderMenu>> MEGA_PATTERN_PROVIDER =
createTyped("mega_pattern_provider", PatternProviderMenuAccessor::create, PatternProviderLogicHost.class);

public static final Supplier<MenuType<CellDockMenu>> CELL_DOCK =
create("cell_dock", CellDockMenu::new, CellDockPart.class);
Expand All @@ -36,4 +37,9 @@ private static <M extends AEBaseMenu, H> Supplier<MenuType<M>> create(
String id, MenuTypeBuilder.MenuFactory<M, H> factory, Class<H> host) {
return DR.register(id, () -> MenuTypeBuilder.create(factory, host).build(MEGACells.makeId(id)));
}

private static <M extends AEBaseMenu, H> Supplier<MenuType<M>> createTyped(
String id, MenuTypeBuilder.TypedMenuFactory<M, H> factory, Class<H> host) {
return DR.register(id, () -> MenuTypeBuilder.create(factory, host).build(MEGACells.makeId(id)));
}
}
14 changes: 0 additions & 14 deletions src/main/java/gripe/_90/megacells/menu/MEGAInterfaceMenu.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 = "<init>")
static PatternProviderMenu create(
MenuType<? extends PatternProviderMenu> menuType, int id, Inventory ip, PatternProviderLogicHost host) {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -47,8 +47,8 @@
},
"widgets": {
"openPriority": {
"left": 154,
"top": 0,
"left": 152,
"top": -5,
"width": 16,
"height": 16
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -47,8 +47,10 @@
},
"widgets": {
"openPriority": {
"left": 154,
"top": 0
"left": 152,
"top": -5,
"width": 20,
"height": 20
},
"lockReason": {
"left": 5,
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/megacells.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d536180

Please sign in to comment.