The bug
When renaming an item in an anvil and emptying the text field (e.g. using the backspace (←
) or Del
key) the name of the result item is not updated. Instead it uses the text which was last in the text field before it was emptied.
Expected would be that when emptying the text field:
if the item has a custom name, the custom name was removed (similar to the current behavior when using only spaces as name)
if the item has no custom name, no result item is shown
Reproduction steps (single backspace)
Place a stone block in an anvil
Backspace until the text field is empty
Look at the output item
[media]
❌ It is named "S" and can be taken out
Reproduction steps (Ctrl
+ backspace)
Place a stone block in an anvil
Backspace once
Ctrl
+ backspace (the text field is now empty)Look at the output item
[media]
❌ It is named "Ston" and can be taken out
Workaround for removing custom name
Currently a custom item name can be removed by only using spaces in the new name. However, due to MC-125046 the item does not stack with other non-renamed items.
Code analysis
Mojang names
net.minecraft.client.gui.screens.inventory.AnvilScreen.onNameChanged(String)
returns if the new name is empty.
Linked issues
blocks 1
discovered while testing 1
is duplicated by 5
Attachments
Comments 27
Sorry everyone; didn't see that Octopus Tea already posted this workaround. But I am confirming that this workaround works for 1.15.2!
The spacebar trick allows the original name to be restored, but it doesn't allow stacking with similar items.
I tested with a book. Steps:
Take one of a stack
rename to something custom
Use space character " " to remove custom name
Expected results:
Renamed book can be stacked with items as before
Actual results:
Renamed book can not be stacked with items
@unknown that is a different issue. Books not stacking with each other is due to their NBT. This bug report is about the function of the anvil before saving the custom name instead.
@@unknown and @unknown, thank you for providing the workaround. However, I have removed your attachments from this ticket because they might be irritating since they don't actually showed the bug and additionally had generic names such as 2020-07-....
I have updated the report and included the workaround, so I hope this change is alright for you.
As @unknown pointed out, the issue that the items do not stack is a different bug (tracked as MC-125046).
I put an unnamed item to the anvil, and delete the original name of the item, I see the output's name is the first character of the original name.