New worlds ignoring global cheatmode (#1003)

Co-authored-by: slprime <31038811+slprime@users.noreply.github.com>
This commit is contained in:
Taran Robertsandslprime authored and GitHub committed 2026-08-14 16:20:31 +03:00
1 parent f93d5977ed
commit 75d53b12ca
2 files changed
+10 -4

No files matched your search

@@ -882,9 +882,14 @@ public class NEIClientConfig {
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
world.config.getTag("inventory.cheatmode")
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (newWorld && Minecraft.getMinecraft().isSingleplayer() && getLockedMode() == -1) {
final int globalMode = global.config.getTag("inventory.cheatmode").getIntValue();
final int worldMode = Math
.min(globalMode, NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (worldMode != globalMode) {
world.config.getTag("inventory.cheatmode").setIntValue(worldMode);
}
}
bootNEI();
@@ -14,8 +14,9 @@ public class NEIInfo {
public static void load(World world) {
OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode");
final boolean worldConfig = NEIClientConfig.isWorldSpecific("inventory.cheatmode");
// kept alive so the WeakReference in Option.slotRef isn't GC'd before copyGlobals/cycle use it
GuiOptionList env = modeOption.parent.synthesizeEnvironment(false);
GuiOptionList env = modeOption.parent.synthesizeEnvironment(worldConfig);
if (!modeOption.optionValid(modeOption.value())) {
modeOption.copyGlobals();
modeOption.cycle();