Skip to content

Commit

Permalink
change keyname; issue 524
Browse files Browse the repository at this point in the history
  • Loading branch information
slprime committed Sep 1, 2024
1 parent 4ad89e8 commit 91262a3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/main/java/codechicken/nei/ClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public static void load() {

public static void postInit() {
loadHandlerOrdering();
loadPluginsList();
GuiContainerManager.registerReloadResourceListener();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/codechicken/nei/NEIClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ public static boolean isKeyHashDown(String string) {
public static String getKeyName(String keyBind) {
final int hash = getKeyBinding(keyBind);

if (NEIClientUtils.unHashKey(hash) == Keyboard.CHAR_NONE) {
if (hash == Keyboard.CHAR_NONE) {
return null;
}

Expand Down Expand Up @@ -665,7 +665,7 @@ public void run() {
config.loadConfig();
NEIModContainer.plugins.add(config);
logger.debug("Loaded {}", clazz.getName());
} catch (Exception e) {
} catch (Throwable e) {
logger.error("Failed to Load {}", clazz.getName(), e);
}
});
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/codechicken/nei/NEIClientUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,23 @@ public static String getKeyHashName(int keyBind) {
keyText.add(NEIClientUtils.translate("key.alt"));
}

return keyText.add("").toString();
return keyText.toString();
}

public static String getKeyName(int keyBind) {
return NEIClientUtils.getKeyHashName(keyBind) + Keyboard.getKeyName(NEIClientUtils.unHashKey(keyBind));
StringJoiner keyText = new StringJoiner(" + ");
String hashText = NEIClientUtils.getKeyHashName(keyBind);
int keyID = NEIClientUtils.unHashKey(keyBind);

if (!hashText.isEmpty()) {
keyText.add(hashText);
}

if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
keyText.add(Keyboard.getKeyName(keyID));
}

return keyText.toString();
}

public static int unHashKey(int keyBind) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/codechicken/nei/NEIModContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void postInit(FMLPostInitializationEvent event) {
public void loadComplete(FMLLoadCompleteEvent event) {
if (CommonUtils.isClient()) {
GuiRecipeTab.loadHandlerInfo();
ClientHandler.loadPluginsList();
}
}

Expand Down

0 comments on commit 91262a3

Please sign in to comment.