Skip to content

Commit

Permalink
Possibly improved XP calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
B1n-ry committed Nov 22, 2023
1 parent 210e5a7 commit 990700c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.parallel=true
loader_version=0.14.24

# Mod Properties
mod_version = 2.0.0-beta.3
mod_version = 2.0.0-beta.4
maven_group = com.b1n_ry.yigd
archives_base_name = youre-in-grave-danger

Expand Down
27 changes: 16 additions & 11 deletions src/main/java/com/b1n_ry/yigd/components/ExpComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ public int getXpDropAmount(ServerPlayerEntity player) {
if (config.expConfig.dropBehaviour == ExpDropBehaviour.VANILLA) {
return Math.min(7 * player.experienceLevel, 100);
} else if (config.expConfig.dropBehaviour == ExpDropBehaviour.PERCENTAGE) {
int currentLevel = player.experienceLevel;
int totalExperience;
if (currentLevel >= 32) {
totalExperience = (int) (4.5 * Math.pow(currentLevel, 2) - 162.5 * currentLevel + 2220);
} else if (currentLevel >= 17) {
totalExperience = (int) (2.5 * Math.pow(currentLevel, 2) - 40.5 * currentLevel + 360);
} else {
totalExperience = (int) (Math.pow(currentLevel, 2) + 6 * currentLevel);
}
totalExperience += player.experienceProgress;
double totalExperience = this.getTotalExperience(player);

return (int) ((config.expConfig.dropPercentage / 100f) * (float) totalExperience);
return (int) ((config.expConfig.dropPercentage / 100f) * totalExperience);
}

return 0;
}

private double getTotalExperience(ServerPlayerEntity player) {
int currentLevel = player.experienceLevel;
double totalExperience;
if (currentLevel >= 32) {
totalExperience = 4.5 * Math.pow(currentLevel, 2) - 162.5 * currentLevel + 2220;
} else if (currentLevel >= 17) {
totalExperience = 2.5 * Math.pow(currentLevel, 2) - 40.5 * currentLevel + 360;
} else {
totalExperience = Math.pow(currentLevel, 2) + 6 * currentLevel;
}
totalExperience += player.experienceProgress;
return totalExperience;
}

public int getXpLevel() {
int totalXp = this.storedXp;

Expand Down

0 comments on commit 990700c

Please sign in to comment.