dragon-forge / HammerLib

HammerLib is an essential tool for developing mods easily. Packed with a lot of utilities, this library provides nearly anything a modder would need, in one handy mod!
8 stars 3 forks source link

org.zeith.hammerlib.util.XPUtil is using experience calculations from Minecraft 1.8 #40

Open lynnpye opened 1 year ago

lynnpye commented 1 year ago

See https://minecraft.wiki/w/Experience#Values_from_Java_Edition_1.3.1_to1.8(14w02a) for reference.

public static int getXPValueFromLevel(int xpLevel)
{
int val = 0;
if(xpLevel >= 30)
    val = (int) (3.5 * Math.pow(xpLevel, 2D) - 151.5 * xpLevel + 2220D);
else if(xpLevel >= 15)
    val = (int) (1.5D * Math.pow(xpLevel, 2D) - 29.5 * xpLevel + 360D);
else
    val = 17 * xpLevel;
return val;
}

This matches the math from the wiki exactly.

You can see this by doing the following: