Skip to content

Commit

Permalink
use ae2's new method of menu initialization that doesn't rely on magi…
Browse files Browse the repository at this point in the history
…c classloading
  • Loading branch information
Mari023 committed Dec 27, 2024
1 parent e628959 commit b56eff7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ neoForge.parchment.mappingsVersion=2024.07.28
mavenGroup=de.mari_023
modID=ae2wtlib

ae2Version=19.0.23-beta
ae2Version=19.1.2-beta
curiosVersion=8.0.0-beta.4+1.20.6

reiVersion=16.0.783
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ static void addToCreativeTab() {
AE2wtlibCreativeTab.add(AE2wtlibItems.MAGNET_CARD);
}

@SuppressWarnings("unused")
static void registerMenus() {
// TODO find a better way to do this.
// classloading causes this to be registered by ae2, but I don't know how reliable this is
var a = WCTMenu.TYPE;
var b = WETMenu.TYPE;
var c = WATMenu.TYPE;
var d = MagnetMenu.TYPE;
var e = TrashMenu.TYPE;
Registry.register(BuiltInRegistries.MENU, WCTMenu.ID, WCTMenu.TYPE);
Registry.register(BuiltInRegistries.MENU, WETMenu.ID, WETMenu.TYPE);
Registry.register(BuiltInRegistries.MENU, WATMenu.ID, WATMenu.TYPE);
Registry.register(BuiltInRegistries.MENU, MagnetMenu.ID, MagnetMenu.TYPE);
Registry.register(BuiltInRegistries.MENU, TrashMenu.ID, TrashMenu.TYPE);
}

public static void registerScreens(RegisterMenuScreensEvent event) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/de/mari_023/ae2wtlib/AE2wtlibForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ public class AE2wtlibForge {
public AE2wtlibForge(IEventBus modEventBus, ModContainer modContainer) {
new AE2wtlibAPIImplementation();
CommonHooks.markComponentClassAsValid(ItemStack.class);// TODO figure out if there is a better way
AE2wtlib.registerMenus();
modContainer.registerConfig(ModConfig.Type.COMMON, AE2wtlibConfig.SPEC,
AE2wtlibAPI.MOD_NAME + ".toml");
modEventBus.addListener((RegisterEvent e) -> {
if (e.getRegistryKey().equals(Registries.MENU)) {
AE2wtlib.registerMenus();
}
if (!e.getRegistryKey().equals(Registries.ITEM))
return;
AE2wtlibItems.init();
AE2wtlib.onAe2Initialized();
AE2wtlibCreativeTab.init();

});
modEventBus.addListener((BuildCreativeModeTabContentsEvent e) -> AE2wtlib.addToCreativeTab());
modEventBus.addListener((RegisterPayloadHandlersEvent event) -> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/mari_023/ae2wtlib/wat/WATMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

public class WATMenu extends PatternAccessTermMenu {
public static final ResourceLocation ID = id("wireless_pattern_access_terminal");
public static final MenuType<WATMenu> TYPE = MenuTypeBuilder.create(WATMenu::new, WATMenuHost.class).build(ID);
public static final MenuType<WATMenu> TYPE = MenuTypeBuilder.create(WATMenu::new, WATMenuHost.class)
.buildUnregistered(ID);

private final WATMenuHost watMenuHost;
private final ToolboxMenu toolboxMenu;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/mari_023/ae2wtlib/wct/TrashMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

public class TrashMenu extends AEBaseMenu implements ISubMenu {
public static final ResourceLocation ID = id("trash");
public static final MenuType<TrashMenu> TYPE = MenuTypeBuilder.create(TrashMenu::new, WCTMenuHost.class).build(ID);
public static final MenuType<TrashMenu> TYPE = MenuTypeBuilder.create(TrashMenu::new, WCTMenuHost.class)
.buildUnregistered(ID);

private final WCTMenuHost host;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/mari_023/ae2wtlib/wct/WCTMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

public class WCTMenu extends CraftingTermMenu {
public static final ResourceLocation ID = id("wireless_crafting_terminal");
public static final MenuType<WCTMenu> TYPE = MenuTypeBuilder.create(WCTMenu::new, WCTMenuHost.class).build(ID);
public static final MenuType<WCTMenu> TYPE = MenuTypeBuilder.create(WCTMenu::new, WCTMenuHost.class)
.buildUnregistered(ID);

public static final String MAGNET_MODE = "magnetMode";
public static final String MAGNET_MENU = "magnetMenu";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class MagnetMenu extends AEBaseMenu implements ISubMenu {
public static final ResourceLocation ID = id("magnet");
public static final MenuType<MagnetMenu> TYPE = MenuTypeBuilder.create(MagnetMenu::new, WCTMenuHost.class)
.build(ID);
.buildUnregistered(ID);

private final WCTMenuHost host;
@Nullable
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/mari_023/ae2wtlib/wet/WETMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

public class WETMenu extends PatternEncodingTermMenu {
public static final ResourceLocation ID = id("wireless_pattern_encoding_terminal");
public static final MenuType<WETMenu> TYPE = MenuTypeBuilder.create(WETMenu::new, WETMenuHost.class).build(ID);
public static final MenuType<WETMenu> TYPE = MenuTypeBuilder.create(WETMenu::new, WETMenuHost.class)
.buildUnregistered(ID);

private final WETMenuHost wetMenuHost;

Expand Down

0 comments on commit b56eff7

Please sign in to comment.