Mojira Archive
MC-257133

Desync when placing large paintings with NBT on a small space

The bug

When placing a painting with NBT in survival mode if the space you're trying to place it on is too small the painting will disappear from your inventory. You can get it back by either clicking on the slot in your inventory or reloading the world

To reproduce

  1. Give yourself a painting item with NBT:
    /give @p painting[entity_data={id:"minecraft:painting",variant:"minecraft:creebet"}] 1 
  1. Try to place it on a block.

Observed result

The item "disappears" from the inventory, reappearing when the slot is clicked from the inventory.

Expected result

The placement would fail completely.

Code analysis (as of 24w18a)

Through the use of Spongepowered Mixins, I was able to come up with a fix, and that is to move line 75 (the "remove 1 from stack" line) of HangingEntityItem.java up a couple of lines into the "if is not client" code block where the placement sound is played