Skip to content

Fix math in getExperienceForTotalLevel for levels between 16 and 30#458

Open
Jabberdrake wants to merge 1 commit into
DragonsPlusMinecraft:1.21.1/6.0.0-devfrom
Jabberdrake:1.21.1/6.0.0-dev
Open

Fix math in getExperienceForTotalLevel for levels between 16 and 30#458
Jabberdrake wants to merge 1 commit into
DragonsPlusMinecraft:1.21.1/6.0.0-devfrom
Jabberdrake:1.21.1/6.0.0-dev

Conversation

@Jabberdrake

Copy link
Copy Markdown

According to the Minecraft Wiki, the formula we can use to calculate the amount of experience needed to go from level 0 to x, for any x between 16 and 30 is: 2.5x^2 - 40.5x + 360.

To avoid dealing with float math, the mod multiplies the whole expression by 2, then divides the result by 2 and simplifies wherever possible. The problem is that while calculating the new expression, the 40.5x term turned into 91x instead of 81x. This PR corrects that mistake.

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