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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#xpBarCap() . These examples are extracted from open source projects. 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
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
/**
 * 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 Project: OpenModsLib   File: EnchantmentUtils.java    License: 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
/**
 * 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
/**
 * 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 Project: OpenModsLib   File: EnchantmentUtils.java    License: 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()));
}