From 517775b37ce61099445b39ae4610901cb218c73c Mon Sep 17 00:00:00 2001 From: AtHisF1nest <41022571+AtHisF1nest@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:21:50 +0200 Subject: [PATCH] fix issue #17509 (#539) Co-authored-by: Marcin Siekierski --- src/main/java/codechicken/nei/LayoutManager.java | 8 ++++++-- src/main/java/codechicken/nei/NEIClientConfig.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/codechicken/nei/LayoutManager.java b/src/main/java/codechicken/nei/LayoutManager.java index ee57ad342..f00694dc6 100644 --- a/src/main/java/codechicken/nei/LayoutManager.java +++ b/src/main/java/codechicken/nei/LayoutManager.java @@ -432,7 +432,8 @@ private boolean getIsAccessibleControlEventKey() { @Override public boolean onButtonPress(boolean rightclick) { if (!rightclick) { - if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) { + if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey() + && NEIClientConfig.canChangeCheatMode()) { NEIClientConfig.cycleSetting("inventory.cheatmode", 3); } else { if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT @@ -456,7 +457,10 @@ public void addTooltips(List tooltip) { else if (cheatMode == 2) modeColor = EnumChatFormatting.RED.toString(); String controlKeyLocalization = translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl"); tooltip.add(modeColor + translate("inventory.options.tip.cheatmode." + cheatMode)); - tooltip.add(modeColor + translate("inventory.options.tip.cheatmode.disable", controlKeyLocalization)); + if (NEIClientConfig.canChangeCheatMode()) { + tooltip.add( + modeColor + translate("inventory.options.tip.cheatmode.disable", controlKeyLocalization)); + } } @Override diff --git a/src/main/java/codechicken/nei/NEIClientConfig.java b/src/main/java/codechicken/nei/NEIClientConfig.java index 4ee7ae795..61f1b9df4 100644 --- a/src/main/java/codechicken/nei/NEIClientConfig.java +++ b/src/main/java/codechicken/nei/NEIClientConfig.java @@ -158,7 +158,7 @@ public boolean optionValid(int index) { return getLockedMode() == -1 || getLockedMode() == index && NEIInfo.isValidMode(index); } }); - checkCheatMode(); + canChangeCheatMode(); tag.getTag("inventory.utilities").setDefaultValue("delete, magnet"); API.addOption(new OptionUtilities("inventory.utilities")); @@ -707,8 +707,13 @@ public static int getCheatMode() { return getIntSetting("inventory.cheatmode"); } - private static void checkCheatMode() { - if (getLockedMode() != -1) setIntSetting("inventory.cheatmode", getLockedMode()); + public static boolean canChangeCheatMode() { + if (getLockedMode() != -1) { + setIntSetting("inventory.cheatmode", getLockedMode()); + return false; + } + + return true; } public static int getLockedMode() {