From d6c49ea142e5e1cf0d5f6a216fab08b0c7e8bd3e Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 14 Apr 2025 11:15:36 +1000 Subject: [PATCH] Modmenu not required --- .../client/config/ModMenuIntegration.java | 27 +++++++++++++++++++ .../client/config/VoxyConfigScreenPages.java | 23 +++------------- src/main/resources/fabric.mod.json | 2 +- 3 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 src/main/java/me/cortex/voxy/client/config/ModMenuIntegration.java diff --git a/src/main/java/me/cortex/voxy/client/config/ModMenuIntegration.java b/src/main/java/me/cortex/voxy/client/config/ModMenuIntegration.java new file mode 100644 index 00000000..b47aa1e3 --- /dev/null +++ b/src/main/java/me/cortex/voxy/client/config/ModMenuIntegration.java @@ -0,0 +1,27 @@ +package me.cortex.voxy.client.config; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.cortex.voxy.common.Logger; +import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; + +public class ModMenuIntegration implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> { + var screen = (SodiumOptionsGUI) SodiumOptionsGUI.createScreen(parent); + //Sorry jelly and douira, please dont hurt me + try { + //We cant use .setPage() as that invokes rebuildGui, however the screen hasnt been initalized yet + // causing things to crash + var field = SodiumOptionsGUI.class.getDeclaredField("currentPage"); + field.setAccessible(true); + field.set(screen, VoxyConfigScreenPages.voxyOptionPage); + field.setAccessible(false); + } catch (Exception e) { + Logger.error("Failed to set the current page to voxy", e); + } + return screen; + }; + } +} \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java index d27b1f91..891cdadb 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenPages.java @@ -21,27 +21,10 @@ import net.minecraft.text.Text; import java.util.ArrayList; import java.util.List; -public class VoxyConfigScreenPages implements ModMenuApi { - public static OptionPage voxyOptionPage = null; +public abstract class VoxyConfigScreenPages { + private VoxyConfigScreenPages(){} - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> { - var screen = (SodiumOptionsGUI)SodiumOptionsGUI.createScreen(parent); - //Sorry jelly and douira, please dont hurt me - try { - //We cant use .setPage() as that invokes rebuildGui, however the screen hasnt been initalized yet - // causing things to crash - var field = SodiumOptionsGUI.class.getDeclaredField("currentPage"); - field.setAccessible(true); - field.set(screen, voxyOptionPage); - field.setAccessible(false); - } catch (Exception e) { - Logger.error("Failed to set the current page to voxy", e); - } - return screen; - }; - } + public static OptionPage voxyOptionPage = null; public static OptionPage page() { List groups = new ArrayList<>(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index de2225f3..82e76ada 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,7 +21,7 @@ "me.cortex.voxy.client.VoxyClient" ], "modmenu": [ - "me.cortex.voxy.client.config.VoxyConfigScreenPages" + "me.cortex.voxy.client.config.ModMenuIntegration" ], "main": [ "me.cortex.voxy.commonImpl.VoxyCommon"