Skip to content

Commit

Permalink
Add an extra level removal for storeExp to handle floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Sep 13, 2024
1 parent 40cd2ce commit a6bcda0
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void storeExp(Player player, int levelChange) {
int totalExp = ExperienceUtils.getPlayerTotalExperience(player);
this.exp += totalExp;
player.giveExperiencePoints(-totalExp); // Removes all levels
player.giveExperienceLevels(-1); //Handles dangling Floating Point Math (RAGE!) Consider it a tax on storing exp :)
} else if (levelChange > 0) {
// Handle fractional progress first, if the player is in the middle of a level
int expInCurrentLevel = (int) (player.experienceProgress * player.getXpNeededForNextLevel());
Expand Down

0 comments on commit a6bcda0

Please sign in to comment.