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.
Related issues
discovered while testing
is duplicated by
Attachments
Comments


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.

I have this problem too. I first saw this issue back in 1.13pre5.
Can confirm for 1.13
Confirmed for 18w30b
Confirmed for 18w31a
Confirmed for 18w32a
Confirmed for 18w33a
Confirmed for 1.13.1-pre1

Confirmed for 19w14b

Confirmed for 1.14 pre-1

Confirmed for 1.14 pre-2

Confirmed for 1.14 pre-3

Confirmed for 1.14 pre-4

Confirmed for 1.14 pre-5

Confirmed for 1.14

Confirmed in 1.13.2 and 1.14.
There is a workaround, type a space on the naming slot, it should reset the name of the item(s).

Confirmed for 1.14.1 pre-1

Confirmed for 1.14.1 pre-2

Confirmed for 1.14.1

Still in 1.14.2. This happens whith default and custom names. In both cases you keep the first character when you empty the text field.
@Octopus Tea, I've try it and unfortunately doesn't work.

Confirmed for 1.15.2

I have found that if, while renaming the item, you press the space key once, you can revert the object back to its original name. Most likely Mojang didn't want to have objects with no name, so that is why they changed it.

Sorry everyone; didn't see that Octopus Tea already posted this workaround. But I am confirming that this workaround works for 1.15.2!

Yes, and the workaround still works in 1.16.1.

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).