mojira.dev
MC-124327

Changing the name of an item and then emptying the text field in an anvil doesn't make the rename unavailable, keeps last non-empty name on output item

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)

  1. Place a stone block in an anvil

  2. Backspace until the text field is empty

  3. Look at the output item
    ❌ It is named "S" and can be taken out

    [media]

Reproduction steps (Ctrl + backspace)

  1. Place a stone block in an anvil

  2. Backspace once

  3. Ctrl + backspace (the text field is now empty)

  4. Look at the output item
    ❌ It is named "Ston" and can be taken out

    [media]

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

Attachments

Comments 27

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

17 more comments
Anonymous Turtle

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:

 

  1. Take one of a stack

  2. rename to something custom

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

 

Jack McKalling

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

[Mod] redstonehelper

gegy

Confirmed

Low

Items, UI

Minecraft 18w02a, Minecraft 18w06a, Minecraft 18w07b, Minecraft 18w11a, Minecraft 1.13-pre1, ..., 21w19a, 21w20a, 1.17 Release Candidate 2, 1.17, 1.17.1

1.20 Pre-release 2

Retrieved