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.

Related issues

Attachments

Comments

migrated
[media][media][media]
migrated

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.

migrated

I have this problem too. I first saw this issue back in 1.13pre5.

Asteraoth

Can confirm for 1.13

Asteraoth

Confirmed for 18w30b

Asteraoth

Confirmed for 18w31a

Asteraoth

Confirmed for 18w32a

Asteraoth

Confirmed for 18w33a

Asteraoth

Confirmed for 1.13.1-pre1

Jack McKalling

Confirmed for 19w14b

Jack McKalling

Confirmed for 1.14 pre-1

Jack McKalling

Confirmed for 1.14 pre-2

Jack McKalling

Confirmed for 1.14 pre-3

Jack McKalling

Confirmed for 1.14 pre-4

Jack McKalling

Confirmed for 1.14 pre-5

Jack McKalling

Confirmed for 1.14

migrated

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

Jack McKalling

Confirmed for 1.14.1 pre-1

Jack McKalling

Confirmed for 1.14.1 pre-2

Jack McKalling

Confirmed for 1.14.1

migrated

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.

migrated

Confirmed for 1.15.2

migrated

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.

migrated

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

migrated

Yes, and the workaround still works in 1.16.1.

migrated

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.

marcono1234

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

migrated

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