本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.xpBarCap方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.xpBarCap方法的具体用法?Java EntityPlayer.xpBarCap怎么用?Java EntityPlayer.xpBarCap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.xpBarCap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRightClickBlock
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
if(!(event.getWorld().getBlockState(event.getPos()).getBlock() instanceof XPBlock) || event.getHand() != EnumHand.MAIN_HAND)
return;
if(!event.getWorld().isRemote)
{
if(event.getEntityPlayer().isSneaking()) //sneaking = add all player XP to the block
{
((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos())).addXP(event.getEntityPlayer().experienceTotal);
event.getEntityPlayer().addExperienceLevel(-event.getEntityPlayer().experienceLevel - 1); // set player XP to 0
}
else //not sneaking = remove exactly enough XP from the block to get player to the next level
{
TileEntityXPBlock te = ((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos()));
EntityPlayer player = event.getEntityPlayer();
int neededXP = player.xpBarCap() - (int)player.experience;
int availableXP = te.removeXP(neededXP);
player.addExperience(availableXP);
}
}
}
示例2: addPlayerXP
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* 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 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();
}
示例3: getExperiencePoints
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static int getExperiencePoints(EntityPlayer player) {
int playerLevel = player.experienceLevel;
player.experienceLevel = 0;
int totalExp = 0;
for (int i = 0; i < playerLevel; i++) {
player.experienceLevel = i;
totalExp += player.xpBarCap();
}
player.experienceLevel = playerLevel;
totalExp += Math.round(player.experience * player.xpBarCap());
return totalExp;
}
示例4: getPlayerXP
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* 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 int getPlayerXP(EntityPlayer player) {
return (int) (getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap());
}