Skip to content

Fix item NBT data getting erased when 'Pick Up as Item' is used + some refactoring#84

Open
Enjoys-1 wants to merge 7 commits into
St3venAU:masterfrom
Enjoys-1:master
Open

Fix item NBT data getting erased when 'Pick Up as Item' is used + some refactoring#84
Enjoys-1 wants to merge 7 commits into
St3venAU:masterfrom
Enjoys-1:master

Conversation

@Enjoys-1

@Enjoys-1 Enjoys-1 commented Jan 27, 2023

Copy link
Copy Markdown

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

@Enjoys-1 Enjoys-1 changed the title Fix item NBT data getting erased when 'Pick Up as Item' is used Fix item NBT data getting erased when 'Pick Up as Item' is used and other fixes Jan 28, 2023
@Enjoys-1 Enjoys-1 changed the title Fix item NBT data getting erased when 'Pick Up as Item' is used and other fixes Fix item NBT data getting erased when 'Pick Up as Item' is used + some refactoring Jan 29, 2023
… new configured armor stand item causing something like a book ban, properly escape armor stand name to prevent NBT tag injection
Aurelien30000 added a commit to Aurelien30000/ArmorStandTools that referenced this pull request Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant