Ah, my bad. My apologizes. It seems to be working with what you posted. Thank you very much
EDIT: Having a really hard time using values other than -1. I'm sure I'll get it eventually though
public static void removeXP(EntityPlayer player, int amt){
if(player.experience > amt && player.experienceLevel > 0) {
player.experienceTotal = player.experienceTotal - amt;
player.experience -= 1F/player.xpBarCap();
}
else if(player.experienceLevel > 0) {
player.experienceTotal = player.experienceTotal - amt;
player.experienceLevel--;
player.experience = (float)(player.xpBarCap()-1)/player.xpBarCap();
if(player.experienceLevel == 0)
player.experience = 0;
}
}
if(player.experienceTotal >= 10){
System.out.println("Removing XP");
player.experienceTotal = player.experienceTotal - 1;
}
Isn't working In fact, it's not doing anything (except printing "Removing XP"). Replacing it with player.addExperience(-1); does work however (with the reported issues).
I'm attempting to remove XP from a player using player.addExperience(-1) (player being an EntityPlayer), however it doesn't quite work properly. When XP reaches below the current level, the XP bar begins to stay empty, and the level stays the same.
I've also tried player.experienceTotal = player.experienceTotal - 1; with no luck.\
Anybody have any suggestions for removing XP from the player?
8 replies
Important Information
By using this site, you agree to our Terms of Use.