Skip to content

Commit

Permalink
Add hotkey to toggle item cheating mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Sep 11, 2016
1 parent 9e6c480 commit ea8d951
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/mezz/jei/config/Config.java
Expand Up @@ -87,6 +87,10 @@ public static boolean isCheatItemsEnabled() {
return cheatItemsEnabled;
}

public static void toggleCheatItemsEnabled() {
cheatItemsEnabled = !cheatItemsEnabled;
}

public static boolean isEditModeEnabled() {
return editModeEnabled;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/mezz/jei/config/KeyBindings.java
Expand Up @@ -23,12 +23,15 @@ public class KeyBindings {
public static final KeyBinding showUses = new KeyBinding("key.jei.showUses", KeyConflictContext.GUI, Keyboard.KEY_U, categoryName);
@Nonnull
public static final KeyBinding recipeBack = new KeyBinding("key.jei.recipeBack", KeyConflictContext.GUI, Keyboard.KEY_BACK, categoryName);
@Nonnull
public static final KeyBinding toggleCheatMode = new KeyBinding("key.jei.toggleCheatMode", KeyConflictContext.GUI, Keyboard.KEY_NONE, categoryName);

public static void init() {
ClientRegistry.registerKeyBinding(toggleOverlay);
ClientRegistry.registerKeyBinding(focusSearch);
ClientRegistry.registerKeyBinding(showRecipe);
ClientRegistry.registerKeyBinding(showUses);
ClientRegistry.registerKeyBinding(recipeBack);
ClientRegistry.registerKeyBinding(toggleCheatMode);
}
}
13 changes: 10 additions & 3 deletions src/main/java/mezz/jei/input/InputHandler.java
Expand Up @@ -215,9 +215,16 @@ private boolean handleKeyDown(char typedChar, int eventKey) {
return false;
}

if (itemListOverlay.isOpen() && KeyBindings.focusSearch.isActiveAndMatches(eventKey)) {
itemListOverlay.setKeyboardFocus(true);
return true;
if (itemListOverlay.isOpen()) {
if (KeyBindings.toggleCheatMode.isActiveAndMatches(eventKey)) {
Config.toggleCheatItemsEnabled();
return true;
}

if (KeyBindings.focusSearch.isActiveAndMatches(eventKey)) {
itemListOverlay.setKeyboardFocus(true);
return true;
}
}

if (!isContainerTextFieldFocused()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/jei/lang/en_US.lang
Expand Up @@ -26,6 +26,7 @@ key.jei.focusSearch=Select Search Bar
key.jei.showRecipe=Show Item Recipe
key.jei.showUses=Show Item Uses
key.jei.recipeBack=Show Previous Recipe Page
key.jei.toggleCheatMode=Toggle Item Cheating Mode

# Config
config.jei.default=Default
Expand Down

0 comments on commit ea8d951

Please sign in to comment.