/**
* The current amount of experience the player has within their Experience Bar.
*/
public float experience;
/** The current experience level the player is on. */
public int experienceLevel;
/**
* The total amount of experience the player has. This also includes the amount of experience within their
* Experience Bar.
*/
public int experienceTotal;
public int xpBarCap()
{
return this.experienceLevel >= 30 ? 62 + (this.experienceLevel - 30) * 7 : (this.experienceLevel >= 15 ? 17 + (this.experienceLevel - 15) * 3 : 17);
}
/**
* Add to player's score
*/
public void addScore(int par1)
{
int j = this.getScore();
this.dataWatcher.updateObject(18, Integer.valueOf(j + par1));
}
public void addExperience(int par1)
{
this.addScore(par1);
int j = Integer.MAX_VALUE - this.experienceTotal;
if (par1 > j)
{
par1 = j;
}
this.experience += (float)par1 / (float)this.xpBarCap();
for (this.experienceTotal += par1; this.experience >= 1.0F; this.experience /= (float)this.xpBarCap())
{
this.experience = (this.experience - 1.0F) * (float)this.xpBarCap();
this.addExperienceLevel(1);
}
}
public void addExperience(int par1)
{
this.addScore(par1);
int j = Integer.MAX_VALUE - this.experienceTotal;
if (par1 > j)
{
par1 = j;
}
this.experience += (float)par1 / (float)this.xpBarCap();
for (this.experienceTotal += par1; this.experience >= 1.0F; this.experience /= (float)this.xpBarCap())
{
this.experience = (this.experience - 1.0F) * (float)this.xpBarCap();
this.addExperienceLevel(1);
}
}
/**
* Add experience levels to this player.
*/
public void addExperienceLevel(int par1)
{
this.experienceLevel += par1;
if (this.experienceLevel < 0)
{
this.experienceLevel = 0;
this.experience = 0.0F;
this.experienceTotal = 0;
}
if (par1 > 0 && this.experienceLevel % 5 == 0 && (float)this.field_82249_h < (float)this.ticksExisted - 100.0F)
{
float f = this.experienceLevel > 30 ? 1.0F : (float)this.experienceLevel / 30.0F;
this.worldObj.playSoundAtEntity(this, "random.levelup", f * 0.75F, 1.0F);
this.field_82249_h = this.ticksExisted;
}
}