Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #1218 (journal restoring XP spent in an enchanting table) #1237

Merged
merged 8 commits into from
Sep 13, 2015

Conversation

DoomFruit
Copy link
Contributor

Issue #1218 (journal restoring all spent XP instead of storing more) arises from the combination of enchantment tables working strangely (a flat level deduction, not a flat XP deduction) and that the "experienceTotal" variable in EntityPlayer isn't actually decreased when levels are removed - it appears to be some kind of lifetime sum.

This means that when someone used an enchanting table, the journal was looking at the lifetime sum of XP and then setting the player's XP value to (that - 10). I've changed the deductXP function in EntityUtilities.java so that it re-calculates an effective total from the player's level and "fill factor", subtracts (amount) from that to get a new total, zeros out the player's experience level and fill factor (the experience total gets (amount) subtracted from it, seeing as how it's some kind of lifetime accumulation) and then gives the player (new total) XP. It is kinda roundabout, but it guarantees that there will be no overflow.

Secondly, the "getXPFromLevel" function in EntityUtilities.java seemed to have an off by one error, meaning that if I used it in the calculations here, it kept increasing your XP even when you were trying to put it away. I've fixed that here.

Finally, I noticed that all of the XP-related variables in EntityPlayer which you accessed are now public, so I took out the reflection helper. There was also another non-localised chat message when looking at journals which didn't belong to you, so I fixed that as well.

Mithion pushed a commit that referenced this pull request Sep 13, 2015
Fix for issue #1218 (journal restoring XP spent in an enchanting table)
@Mithion Mithion merged commit 53e11ad into Mithion:master Sep 13, 2015
@DoomFruit DoomFruit deleted the JournalFix branch September 13, 2015 07:58
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.

2 participants