fix crafting order chat notification showing item name in wrong locale - #1361
fix crafting order chat notification showing item name in wrong locale#1361Eldrinn-Elantey wants to merge 3 commits into
Conversation
item name was resolved server-side via func_151000_E(), always producing English text. replaced with ChatComponentTranslation so the client translates it in their own locale, preserving brackets and hover tooltip.
|
|
||
| @Override | ||
| public IChatComponent getChatComponent() { | ||
| return this.getItemStack().func_151000_E(); |
There was a problem hiding this comment.
Can’t we use ChatComponentItemName from GTNHLib?
https://github.com/GTNewHorizons/GTNHLib/blob/master/src/main/java/com/gtnewhorizon/gtnhlib/chat/customcomponents/ChatComponentItemName.java
There was a problem hiding this comment.
returns just stack.getDisplayName() with no brackets or hover event. There's also no mixin in GTNHLib that adds that rendering in GuiChat. Replacing with it would drop the [...] brackets and the item tooltip hover, which are part of vanilla func_151000_E() behavior that this fix preserves.
There was a problem hiding this comment.
Still, couldn’t these two lines be replaced?
final String translationKey = itemStack.getItem().getUnlocalizedName(itemStack) + ".name";
final IChatComponent nameComponent = new ChatComponentTranslation(translationKey);Also, for the hover event, it might be worth adding an option to ChatComponentItemName.
There was a problem hiding this comment.
Good points. We ended up moving the fix to Hodgepodge (GTNewHorizons/Hodgepodge#924) so it applies globally to all mods, not just AE2U.
On ChatComponentTranslation: it works for simple items but breaks for anything with a custom display name (renamed items, enchanted items, items with NBT-driven names) since getUnlocalizedName() won't reflect those. ChatComponentItemName with full ItemStack serialization handles all cases correctly.
On the hover event in ChatComponentItemName: agreed it would be cleaner to have it there rather than in a separate GuiChat mixin. Filed GTNewHorizons/GTNHLib#396 for the brackets change already. The hover tooltip is currently handled by a dedicated mixin in Hodgepodge to avoid the NBT toString crash from GTNH#21933/#21940 - if GTNHLib adds a safe binary-serialized hover event we can drop that mixin.
|
The fix has been moved to Hodgepodge where it applies globally to all mods, not just AE2U. See GTNewHorizons/Hodgepodge#924. Closing this PR. |
item name in crafting completion chat message was resolved server-side via
func_151000_E(), which always produces English text on a dedicated server. replaced withChatComponentTranslationso the client translates it in their own locale, preserving[...]brackets and hover tooltip.