XP Duplication
JoshMayberry opened this issue ยท 7 comments
Sometimes, I will use the xp book when I have around 27 levels- and it will only take about 10 from me and fill the book entirely.
I can then use the book to gain about 20 levels of free xp.
Other times it does not do this. If I can pin down exactly what causes this, I will let you know- but for now I thought I would make you aware that this is an issue; perhaps you can include a sanity check on how many levels are taken, etc. :)
No, it is on an empty book.
I'm not too good at Java, nor have I ever made a mod before (my hat is off to you, you are doing a great job).
It looks like OpenBlocks adds negative experience for their exp drain instead of zeroing it out and adding back the difference.
Would doing somthing similar like this for XpItem.use be more robust?
// Check max value
if (remainingPlace < playerExperience) {
user.addExperience(-remainingPlace);
stack.setDamage(0);
} else {
user.totalExperience = 0;
user.experienceProgress = 0;
user.experienceLevel = 0;
stack.setDamage(remainingPlace-playerExperience);
}
Perhaps the server and client get out of sync a bit because the exp is completely removed and then added back, so just removing a bit would not cause that to happen? Just a complete shot in the dark.
I'll check it out, thanks. Is the book already a bit filled when you do it? For the level check, no: actually the first level needs way less xp than the 30th to be taken as you may know so you can't really check it like that (I think)
I've rewrote those lines (almost as you said) to avoid any reference problem (if it is) but this issue normally shouldn't happen because this mod has a very easy concept that can't be failed. I don't think it can be a client/server problem as only the server makes the changes but I don't know how minecraft server protocol are coded so maybe. I'll upload a new release on GitHub (especially for you), so let me know if it happens again with this new release ;)
Sure thing. Sorry for the hassle. I will let you know if the issue happens again with the different method.
Mostly, I was just trying to think of a different way to do the same thing- in hopes that it somehow solves the bug.
Someone explained me a bug he found and it may be the same as you actually! But the way he explained it to me made me find the real issue. I'll fix this ;)
I'm glad to tell you that this issue is fixed! I should publish a new release here and on CurseForge tonight