Global XP

Global XP

9M Downloads

[1.12] More XP than what I have on hand is deposited

DoomRater opened this issue ยท 3 comments

commented

After I retrieve experience for an anvil repair, a deposit somewhere else, or an enchantment, when I go to deposit the remaining XP again it acts like I never spent it to begin with. I'm baffled as to why this is happening.

commented

This is caused by Minecraft handling XP in a weird way. I am aware of this issue already, but it doesn't seem like I can do anything against it.

commented

I took a peek at how OpenBlocks and by extension the OpenMods EnchantmentUtils class AddPlayerXP does it. It seems to be doing a lot of calculations and then setting the player's experience directly instead of calling a method to change the player's XP. In fact, there's a comment in there about how Minecraft doesn't update experienceTotal properly, so they use a workaround.
https://github.com/OpenMods/OpenModsLib/blob/master/src/main/java/openmods/utils/EnchantmentUtils.java

commented

Thanks, I will take a look at it.