Skip to content

Commit

Permalink
fix issue #17509 (GTNewHorizons#539)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Siekierski <[email protected]>
  • Loading branch information
2 people authored and RaidhoSketch committed Oct 6, 2024
1 parent cc9715d commit 517775b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/main/java/codechicken/nei/LayoutManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -456,7 +457,10 @@ public void addTooltips(List<String> 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
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/codechicken/nei/NEIClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 517775b

Please sign in to comment.