当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.xpBarCap方法代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:bl4ckscor3,项目名称:GlobalXP,代码行数:25,代码来源:EventHandler.java

示例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();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:TileEntityAerialInterface.java

示例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;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:13,代码来源:TF2Util.java

示例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());
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:TileEntityAerialInterface.java


注:本文中的net.minecraft.entity.player.EntityPlayer.xpBarCap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。