Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto_pickup.sc for new versions #412

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

WesleyJ-128
Copy link

At some point (potentially 1.20.6 when the component system was added), the nbt contained in item entities was changed to include the count of the items. This breaks auto_pickup.sc, as it checks for the nbt of the items to match, which will not happen when the counts are unequal— my solution is to use replace() to remove the count field from the nbt before comparing. This should be backwards-compatible as replace() will do nothing if the match is unsuccessful.

@WesleyJ-128 WesleyJ-128 marked this pull request as draft December 12, 2024 21:13
@WesleyJ-128
Copy link
Author

WesleyJ-128 commented Dec 12, 2024

As the commit message notes, the regex fix deletes the counts in shulker box contents as well. To fix this, I copy the nbt of the inventory item and modify its count to match that of the picked-up item, then compare if the modified nbt equals the picked-up item's nbt. Additionally, the nbt is checked for a count field before it is modified to retain backwards compatibility.

@WesleyJ-128 WesleyJ-128 marked this pull request as ready for review December 12, 2024 21:50
@WesleyJ-128 WesleyJ-128 marked this pull request as draft December 13, 2024 01:26
@WesleyJ-128
Copy link
Author

Fixed another issue with the stackableShulkerBoxes carpet rule— the pickup script would stack filled boxes together, which is incorrect. There is now a change in behavior from previous versions; the script will automatically stack empty boxes, but this is convenient and empty boxes can be stacked in the inventory anyway. If original functionality is desired, remove && has(item_nbt, 'components') from line 45.

@WesleyJ-128 WesleyJ-128 marked this pull request as ready for review December 13, 2024 01:45
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