Java Code Examples for net.minecraft.entity.player.EntityPlayer#xpBarCap()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#xpBarCap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerXP.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addPlayerXP(EntityPlayer player, int amount) {
	int experience = getPlayerXP(player) + amount;
	player.experienceTotal = experience;
	player.experienceLevel = getLevelForExperience(experience);
	int expForLevel = getExperienceForLevel(player.experienceLevel);
	player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap();
}
 
Example 2
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method is copied from OpenMods' OpenModsLib
 * https://github.com/OpenMods/OpenModsLib/blob/master/src/main/java/openmods/utils/EnchantmentUtils.java
 * @param player
 * @return
 */

private static void addPlayerXP(EntityPlayer player, int amount){
    int experience = getPlayerXP(player) + amount;
    player.experienceTotal = experience;
    player.experienceLevel = getLevelForExperience(experience);
    int expForLevel = getExperienceForLevel(player.experienceLevel);
    player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap();
}
 
Example 3
Source File: EnchantmentUtils.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static void addPlayerXP(EntityPlayer player, int amount) {
	int experience = getPlayerXP(player) + amount;
	player.experienceTotal = experience;
	player.experienceLevel = EnchantmentUtils.getLevelForExperience(experience);
	int expForLevel = EnchantmentUtils.getExperienceForLevel(player.experienceLevel);
	player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap();
}
 
Example 4
Source File: PlayerXP.java    From GT-Classic with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Thanks to OpenMods/OpenBlocks for being MIT which allows me to use the code
 * below
 */
public static int getPlayerXP(EntityPlayer player) {
	return (int) (getExperienceForLevel(player.experienceLevel) + (player.experience * player.xpBarCap()));
}
 
Example 5
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 2 votes vote down vote up
/**
 * This method is copied from OpenMods' OpenModsLib
 * https://github.com/OpenMods/OpenModsLib/blob/master/src/main/java/openmods/utils/EnchantmentUtils.java
 * @param player
 * @return
 */

private static int getPlayerXP(EntityPlayer player){
    return (int)(getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap());
}
 
Example 6
Source File: EnchantmentUtils.java    From OpenModsLib with MIT License 2 votes vote down vote up
/**
 * Be warned, minecraft doesn't update experienceTotal properly, so we have
 * to do this.
 *
 * @param player
 * @return
 */
public static int getPlayerXP(EntityPlayer player) {
	return (int)(EnchantmentUtils.getExperienceForLevel(player.experienceLevel) + (player.experience * player.xpBarCap()));
}