Using the tool 'Pick Up as Item' causes all items that are equipped on the armor stand to lose all NBT data apart from enchantments and durability (when the given configured armor stand item is placed).
I fixed it using a bit of reflection to retrieve the NBT directly from the ItemStack and then convering it to string using .toString(). Since all the string generating is handled by the server, the code could be simplified a bit by removing some not used functions.
Now all item NBT (even custom NBT added by plugins) is preserved when the armor stand is converted to item and back to entity.
Also, I got rid of /give and now the item is placed directly into the player's inventory (if it's full, the item is dropped at the armor stand)
Using the tool 'Pick Up as Item' causes all items that are equipped on the armor stand to lose all NBT data apart from enchantments and durability (when the given configured armor stand item is placed).
I fixed it using a bit of reflection to retrieve the NBT directly from the ItemStack and then convering it to string using .toString(). Since all the string generating is handled by the server, the code could be simplified a bit by removing some not used functions.
Now all item NBT (even custom NBT added by plugins) is preserved when the armor stand is converted to item and back to entity.
Also, I got rid of /give and now the item is placed directly into the player's inventory (if it's full, the item is dropped at the armor stand)
Tested on 1.19.2, 1.18.2 and 1.17.1