Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4576

ItemStacks serialized with attributes in 1.12.2 cannot be deserialized correctly in 1.13.2

XMLWordPrintable

    • git-Spigot-f56e2e7-07e504c (MC: 1.13.2)
    • Yes

      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
      

            Unassigned Unassigned
            RecursiveG RecursiveG
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: