Enchantment Descriptions

Enchantment Descriptions

148M Downloads

[BUG] Error key binding prompt display

Giant-Salted-Fish opened this issue ยท 2 comments

commented

Minecraft Version

1.16.5

Mod Version

7.1.25

Mod Loader

Forge

What environment are you running the mod in?

Client

Issue Description

Someone has reported a key prompt display issue when using this mod with my Key Binding Patch mod. Original issue is here: Giant-Salted-Fish/Key-Binding-Patch#6.

I have reviewed the code of this mod and the cause is here:

event.getToolTip().add(new StringTextComponent(TextFormatting.GRAY + I18n.format("tooltip.enchdesc.activate", TextFormatting.LIGHT_PURPLE, I18n.format(this.keybind.getTranslationKey()), TextFormatting.GRAY)));

Although it is called KeyBinding#getTranslationKey() in mcp mapping, it is actually called KeyBinding#saveString() in official mapping. And this method is not suitable to retrieve localized key display name because it only returns the key code of the key binding without the modifiers.

Appropriate method to use here is KeyBinding#func_238171_j_(), which has corresponding name KeyBinding#getTranslatedKeyMessage() in official mapping. It returns a ITextComponent instance that contains the right localized display string of the binding key. It is also the method that being used in the ControlsScreen to display the key of the key binding.

Hence replace I18n.format(this.keybind.getTranslationKey()) with this.keybind.func_238171_j_().getString() should be able to fix this issue.

commented

Thank you for looking into this issue and providing detailed info on what to fix. I've verified the issue has been fixed and have uploaded a new version. It's fixed in 7.1.27

commented

Thank you!