-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major
-
None
-
Affects Version/s: None
-
None
-
CraftBukkit version 4434-Spigot-d421948-ec571d7 (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
-
Yes
Hello.
When serializing a shulker box in 1.21.1 and deserializing it in 1.21.4, the content is incorrectly deserialized if it had things to be migrated due to data format change.
I will attach a very basic plugin that can reproduce this bug.
For instance, let's take the "custom model data" that changed. Give yourself an item with a custom model data in 1.21.1, e.g. with
/give @a paper[custom_name='["",{"text":"Custom Paper","italic":false}]',custom_model_data=42]
First, save this item (hold it in your main hand and /saveitem paper).
item: ==: org.bukkit.inventory.ItemStack v: 3955 type: PAPER meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: '{"text":"","extra":[{"text":"Custom Paper","italic":false}]}' custom-model-data: 42
Then, put it in a shulker box and serialize it (/saveitem shulker).
item: ==: org.bukkit.inventory.ItemStack v: 3955 type: SHULKER_BOX meta: ==: ItemMeta meta-type: TILE_ENTITY internal: H4sIAAAAAAAA/2VPTWvCQBCdNAqag5489VLmKP6C0FPFg7eCvZUSppuJLtmPkJ1ArPjfu1vBFjqX95j35g2vAChg8WK8andOtJzf6JhDNkKciOeEc5juhW0oIs9ymCo/OEk8g8nBeIkJhfK2846dhBwerXasemqkVEMQbyvrazZVTULxbD2D1T+HI8vwfEEepScs3y+ohYxWWDZkAm9QooIlbn/sT6/UcY/Xj/serzCDB13D8je6S6bU4iu1uMl/PofTYFruq08f234DKph/owgBAAA= blockMaterial: SHULKER_BOX
Now, go to a 1.21.4 server. Load the paper item (/loaditem paper). You will see that the custom model data has been properly migrated: if you serialize it again you will see
item: ==: org.bukkit.inventory.ItemStack v: 4189 type: PAPER meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: '{"text":"","extra":[{"text":"Custom Paper","italic":false}]}' custom-model-data: ==: CustomModelData floats: - 42.0 flags: [] strings: [] colors: []
Now, deserialize the shulker (/loaditem shulker). You can already see a warning in console:
[Server thread/ERROR]: Tried to load invalid item: 'Not a map: 42 missed input: {"minecraft:custom_model_data":42}'
Open the shulker box and take the paper out: it has lost its custom model data. You can see that by re-serializing it:
item: ==: org.bukkit.inventory.ItemStack v: 4189 type: PAPER meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: '{"text":"","extra":[{"text":"Custom Paper","italic":false}]}'
In my case, it completely prevents me from upgrading to 1.21.4 because all of my players backpack will contain broken items...
I am afraid I cannot help in fixing this bug because I cannot wrap my head around how CraftItemMeta is working, seems like a can of worms. I just hope you can do something to fix that...