Game crashes when using an item with a tag in the CanDestroy or CanPlaceOn NBT tag
The bug
An item that has a block tag (like #minecraft:planks) in the CanPlaceOn or CanDestroy NBT tag, can crash the game. This can happen in two ways:
- By selecting the hotbar slot the item is in, while being in Adventure mode.
- By opening the inventory and hovering the mouse over the slot the item is in. This can be circumvented by setting the HideFlags NBT tag to 24, which hides the CanPlaceOn/CanDestroy flag.
The cause of this issue may be that block tags have not been fully implemented for the CanPlaceOn/CanDestroy NBT tag, or that the game does not know how to display the name of a block tag.
How to reproduce
- Run either of the following commands:
/give @s minecraft:stone{CanPlaceOn:["#minecraft:planks"]}
/give @s minecraft:stone{CanDestroy:["#minecraft:planks"]} - Perform either of the actions listed above. The game crashes immediately.
- Reopen the world. It is possible that the item is still selected and the game crashes immediately, or that the item is not selected. It may also occur that the player data is gone.
Crash report
Description: Rendering screen g: Non [a-z0-9_.-] character in namespace of location: #minecraft:planks at mx.<init>(SourceFile:33) at mx.<init>(SourceFile:41) at atd.a(SourceFile:143) at ams.a(SourceFile:681) at bqv.a(SourceFile:99) at bqv.a(SourceFile:95) at brz.a(SourceFile:681) at brq.b(SourceFile:176) at brz.a(SourceFile:642) at bzx.a(SourceFile:997) at bne.b(SourceFile:820) at bne.a(SourceFile:380) at net.minecraft.client.main.Main.main(SourceFile:140)