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
Open
Fix item NBT data getting erased when 'Pick Up as Item' is used + some refactoring#84Enjoys-1 wants to merge 7 commits into
Enjoys-1 wants to merge 7 commits into
Conversation
added 4 commits
January 27, 2023 21:27
…ctor of function createItemLore()
… the item at the armor stand
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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