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

ItemStack Deserialization Issues

XMLWordPrintable

      The way ItemStack conversion was handled in CraftBukkit is faulty and still has issues in regards to old Spawn Eggs. There are honestly numerous flaws with the implementation.

       

      1st, ItemStack conversion is occurring before and after item meta apply process.

      This causes the damage value on a spawn egg to be converted, then the item meta applies.

       

      For an old itemstack that was serialized before Bukkit added Support for Spawn Egg Item Meta, it will be type UNSPECIFIC.

       

      So Vanilla converts say Damage Value 100 to a Horse Egg. Then Item Meta applies, and erases the type data that Vanilla just added.

       

      This can be fixed with the following patch: https://github.com/PaperMC/Paper/blob/master/Spigot-Server-Patches/0198-Fix-ItemStack-Data-Conversion.patch

       

      Following up, embedded ID's in Spawn Eggs are not being ran through the NMS Converters, resulting in any old spawn egg before 1.11.2 from being valid, as it uses invalid spawn ID's.

       

      The following patch also resolves this issue

      https://github.com/starlis/empirecraft/blob/5b17e8fac1e6f1cb8f2bbe288a6c60676532669d/patches/server/0099-Convert-Horse-Eggs-in-Meta-Deserialization.patch

      However this patch identifies a serious flaw in the Item Meta's deserialization system. Spawn Eggs may not be the only thing affected by this.

      Item Meta handlers needs to try to load the data from the loaded NBT in internal tag if it cant find it in its expected field.

      New Item Meta handlers (such as an expected Shulker Box to come) really must handle both cases, of serialization data that is in and not in the "simplified format".

      Servers are losing data due to this bug.

      I am not expecting you to copy my patches exactly (But they are MIT licensed if you wish to copy it), but to fix this properly on the implementation of Item Meta itself ideally.

            Unassigned Unassigned
            Aikar Daniel Ennis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: