Skip to content

fixed resetCurrentXp being overridden on respawn causing xp duplication#440

Open
uema5a wants to merge 1 commit into
Globox1997:1.21from
uema5a:fix/reset-current-xp
Open

fixed resetCurrentXp being overridden on respawn causing xp duplication#440
uema5a wants to merge 1 commit into
Globox1997:1.21from
uema5a:fix/reset-current-xp

Conversation

@uema5a
Copy link
Copy Markdown

@uema5a uema5a commented Apr 30, 2026

Hey! First off, thanks for maintaining LevelZ — it's been a lot of fun to play with. I ran into a bug and wanted to contribute a fix!

Summary

  • Fixed a bug where resetCurrentXp=true with levelRetainPercentage=100 (default) caused XP duplication on death

Root Cause

In the AFTER_RESPAWN handler, the reset block ran before updatePlayerSkills(newPlayer, oldPlayer), which internally calls setLevelProgress(oldLevelManager.getLevelProgress()) and overwrites the reset. As a result, the player dropped a LevelExperienceOrbEntity but kept their full progress — pure XP duplication.

Fix

Moved the resetCurrentXp reset block inside the else branch, after updatePlayerSkills, so the reset is applied after the state copy and cannot be overwritten.

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