[1.12] More XP than what I have on hand is deposited
DoomRater opened this issue ยท 3 comments
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.
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.
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