[SPIGOT-4576] ItemStacks serialized with attributes in 1.12.2 cannot be deserialized correctly in 1.13.2 Created: 13/Jan/19 Updated: 13/Jan/19 Resolved: 13/Jan/19 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | RecursiveG | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | 1.13.2, attribute, deserialization, itemstack |
Version: | git-Spigot-f56e2e7-07e504c (MC: 1.13.2) |
Guidelines Read: | Yes |
Description |
Particularly, attribute modifiers are lost. Give yourself an item with attributes: /give @p diamond_sword 1 0 {AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:1000,Operation:0,UUIDMost:64497,UUIDLeast:746848}]} Serialize it using git-Spigot-e8ded36-acbc348 (MC: 1.12.2): Player p = ...; ItemStack it = p.getItemInHand(); YamlConfiguration cfg = new YamlConfiguration(); cfg.set("item", it); cfg.save(new File(getDataFolder(), "item.yml")); The generated YAML looks like this: item: ==: org.bukkit.inventory.ItemStack type: DIAMOND_SWORD meta: ==: ItemMeta meta-type: UNSPECIFIC internal: H4sIAAAAAAAAAHWNMQ6CQBBFv1ljFggN8RzegYSGRLCiZ8SRTMzummW4s601jWtjZ/nyft7PgQxVrRrluip34SZ34bjkAHYGdhjapguLAtvbIPvimSlxwaPBoXZh9Umal0X5q/TkGMeZPUeZTqRK06MhRzOnxOXJkVSCTw+w2P8fAx9NnKb/ngAAAA== Then load it using git-Spigot-f56e2e7-07e504c (MC: 1.13.2) Player p = (Player) sender; YamlConfiguration cfg = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "item.yml")); p.getLocation().getWorld().dropItem(p.getLocation(), cfg.getItemStack("item")); The deserialized item has its attributes missing. I've written a workaround trying to convert the Itemstack yaml: https://github.com/RecursiveG/YamlUpgrader which generates yaml that can be loaded by 1.13.2: item: ==: org.bukkit.inventory.ItemStack v: 1631 type: DIAMOND_SWORD meta: ==: ItemMeta meta-type: UNSPECIFIC attribute-modifiers: GENERIC_ATTACK_DAMAGE: - ==: org.bukkit.attribute.AttributeModifier amount: 1000.0 name: generic.attackDamage uuid: 00000000-0000-fbf1-0000-0000000b6560 operation: 0 |
Comments |
Comment by md_5 [ 13/Jan/19 ] |
Only one way to get familiar
|
Comment by RecursiveG [ 13/Jan/19 ] |
The workaround is more of a disposable tool since we only have one or two configs need to be upgraded. |
Comment by md_5 [ 13/Jan/19 ] |
Have you considered attempting+submitting a fix yourself? Seems a bit redundant to write an external tool as opposed to fixing it directly |