Remove per-world config override (#1094)

Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
slprimeandMartin Robertz authored and GitHub committed 2026-11-02 18:20:18 +02:00
1 parent a0b2430458
commit afc8a2380b
35 files changed
+76 -364

No files matched your search

@@ -67,6 +67,7 @@ public class NEIClientConfig {
private static boolean pluginNEIConfigLoaded;
private static boolean enabledOverride;
private static String worldPath;
private static final String CHEAT_MODE_KEY = "cheatmode";
public static Logger logger = LogManager.getLogger("NotEnoughItems");
public static File configDir = new File(CommonUtils.getMinecraftDir(), "config/NEI/");
@@ -155,6 +156,16 @@ public class NEIClientConfig {
.getIntValue(-1);
API.addOption(new OptionCycled("inventory.cheatmode", 3) {
@Override
public int value() {
return getCheatMode();
}
@Override
public void setValue(int value) {
setCheatMode(value);
}
@Override
public boolean optionValid(int index) {
return getLockedMode() == -1 || getLockedMode() == index && NEIInfo.isValidMode(index);
@@ -545,23 +556,18 @@ public class NEIClientConfig {
OptionList.setOptionList(new OptionList("nei.options") {
@Override
public ConfigSet globalConfigSet() {
public ConfigSet configSet() {
return global;
}
@Override
public ConfigSet worldConfigSet() {
return world;
}
@Override
public OptionList configBase() {
return this;
}
@Override
public GuiOptionList getGui(GuiScreen parent, OptionList list, boolean world) {
return new GuiNEIOptionList(parent, list, world);
public GuiOptionList getGui(GuiScreen parent, OptionList list) {
return new GuiNEIOptionList(parent, list);
}
});
}
@@ -928,15 +934,15 @@ public class NEIClientConfig {
specificDir.mkdirs();
}
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
world = new ConfigSet(new File(specificDir, "NEI.dat"));
if (newWorld && Minecraft.getMinecraft().isSingleplayer() && getLockedMode() == -1) {
final int globalMode = global.config.getTag("inventory.cheatmode").getIntValue();
final int globalMode = getCheatMode();
final int worldMode = Math
.min(globalMode, NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (worldMode != globalMode) {
world.config.getTag("inventory.cheatmode").setIntValue(worldMode);
setCheatMode(worldMode);
}
}
@@ -950,9 +956,6 @@ public class NEIClientConfig {
}
private static void onWorldLoad() {
world.config.setComment(
"World based configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
setWorldDefaults();
creativeInv = new ItemStack[54];
LayoutManager.searchField.setText(getSearchExpression());
@@ -1058,14 +1061,8 @@ public class NEIClientConfig {
}
public static boolean isWorldSpecific(String setting) {
if (world == null) return false;
ConfigTag tag = world.config.getTag(setting, false);
return tag != null && tag.value != null;
}
public static ConfigTag getSetting(String s) {
return isWorldSpecific(s) ? world.config.getTag(s) : global.config.getTag(s);
return global.config.getTag(s);
}
public static boolean getBooleanSetting(String s) {
@@ -1211,12 +1208,18 @@ public class NEIClientConfig {
}
public static int getCheatMode() {
if (world != null && world.nbt.hasKey(CHEAT_MODE_KEY)) return world.nbt.getInteger(CHEAT_MODE_KEY);
return getIntSetting("inventory.cheatmode");
}
public static void setCheatMode(int mode) {
if (world != null) world.nbt.setInteger(CHEAT_MODE_KEY, mode);
else setIntSetting("inventory.cheatmode", mode);
}
public static boolean canChangeCheatMode() {
if (getLockedMode() != -1) {
setIntSetting("inventory.cheatmode", getLockedMode());
setCheatMode(getLockedMode());
return false;
}