Modmenu not required

This commit is contained in:
mcrcortex
2025-04-14 11:15:36 +10:00
parent a521e34f49
commit d6c49ea142
3 changed files with 31 additions and 21 deletions

View File

@@ -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;
};
}
}

View File

@@ -21,27 +21,10 @@ import net.minecraft.text.Text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class VoxyConfigScreenPages implements ModMenuApi { public abstract class VoxyConfigScreenPages {
public static OptionPage voxyOptionPage = null; private VoxyConfigScreenPages(){}
@Override public static OptionPage voxyOptionPage = null;
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 page() { public static OptionPage page() {
List<OptionGroup> groups = new ArrayList<>(); List<OptionGroup> groups = new ArrayList<>();

View File

@@ -21,7 +21,7 @@
"me.cortex.voxy.client.VoxyClient" "me.cortex.voxy.client.VoxyClient"
], ],
"modmenu": [ "modmenu": [
"me.cortex.voxy.client.config.VoxyConfigScreenPages" "me.cortex.voxy.client.config.ModMenuIntegration"
], ],
"main": [ "main": [
"me.cortex.voxy.commonImpl.VoxyCommon" "me.cortex.voxy.commonImpl.VoxyCommon"