Fix XP increase when restoring advancements on world switch#47
Merged
Conversation
When granting advancement criteria via awardCriteria(), some Minecraft advancements reward XP, causing the player's experience to increase on every world switch. Fix by saving the player's current XP before granting advancement criteria in setAdvancements() and restoring it afterward. Also add test testGetInventoryAdvancementsPreservesExperience to verify that setTotalExperience is called after advancement criteria are awarded, ensuring XP is properly restored. Agent-Logs-Url: https://github.com/BentoBoxWorld/InvSwitcher/sessions/dde552a1-224e-42d1-94cb-218e3609eaf8 Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Agent-Logs-Url: https://github.com/BentoBoxWorld/InvSwitcher/sessions/dde552a1-224e-42d1-94cb-218e3609eaf8 Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix experience points increase when teleporting worlds
Fix XP increase when restoring advancements on world switch
May 20, 2026
|
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.



Some Minecraft advancements reward XP when their criteria are awarded. When
setAdvancements()restored a player's advancements on world entry, those XP rewards fired, increasing the player's experience beyond the stored value on every teleport.Changes
Store.setAdvancements(): Save the player's current XP before callingawardCriteria()on any advancement, then restore it afterward. Returns early if there are no stored advancements to avoid unnecessary XP calls.StoreTest: AddtestGetInventoryAdvancementsPreservesExperience— stores a player with a completed advancement, then callsgetInventoryand assertssetTotalExperienceis called the expected number of times (including the restoration call insidesetAdvancements).