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


Java FoodStats.addStats方法代码示例

本文整理汇总了Java中net.minecraft.util.FoodStats.addStats方法的典型用法代码示例。如果您正苦于以下问题:Java FoodStats.addStats方法的具体用法?Java FoodStats.addStats怎么用?Java FoodStats.addStats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.FoodStats的用法示例。


在下文中一共展示了FoodStats.addStats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleHunger

import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
/** Handles the hunger setting, returns if hunger is enabled. */
private boolean handleHunger(EntityPlayer player, FoodStats foodStats) {
	EnumHunger hunger = AdvHealthOptions.config.<EnumHunger>get(AHOWorldConfig.miscHunger);
	if (hunger == EnumHunger.ENABLE) return true;
	
	// Make direct changes to the food meter affect health directly.
	if ((hunger == EnumHunger.HEALTH) && foodLevelSet) {
		int change = (foodStats.getFoodLevel() - 8);
		if (change > 0) player.heal(change);
		else if (change < 0) player.attackEntityFrom(DamageSource.starve, -change);
	}
	
	// Reset the food level and saturation.
	setFoodLevel(player, 0);
	foodStats.addStats(8, 20.0F);
	foodLevelSet = true;
	
	return false;
}
 
开发者ID:copygirl,项目名称:AdvHealthOptions,代码行数:20,代码来源:AHOProperties.java

示例2: doOnServer

import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public void doOnServer(EntityPlayer player, NBTTagCompound dataFromClient)
{
    FoodStats food = player.getFoodStats();
    switch (dataFromClient.getInteger(OPERATION_KEY))
    {
        case ADD:
            food.addStats((int) dataFromClient.getFloat(AMOUNT_KEY), 0);
            break;
        case SUBTRACT:
            food.addStats((int) -dataFromClient.getFloat(AMOUNT_KEY), 0);
            break;
        case SET:
            food.addStats(-food.getFoodLevel(), 0);
            food.addStats((int) dataFromClient.getFloat(AMOUNT_KEY), 0);
            break;
    }
}
 
开发者ID:CCM-Modding,项目名称:Pay2Spawn,代码行数:19,代码来源:PlayerModificationType.java

示例3: entityUpdate

import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@SubscribeEvent
public void entityUpdate(LivingEvent.LivingUpdateEvent event)
{
	if(!isPlayer(event.entityLiving))
	{
		return;
	}

	EntityPlayer player = (EntityPlayer)event.entityLiving;
	PlayerCapabilities capabilities = player.capabilities; 

	IAttributeInstance movementSpeed = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

	if(!checkEquips(player))
	{
		event.entityLiving.stepHeight = 0.5F;
		capabilities.allowFlying = player.capabilities.isCreativeMode;

		if(!ModConfig.useSpeedPotion)
		{
			movementSpeed.setBaseValue(0.1);
		}

		FoodStats fs = player.getFoodStats();
		if(fs != null)
		{
			fs.addStats(20, 5);
		}

		return;
	}

	player.stepHeight = 1;

	capabilities.allowFlying = true;
	if(!ModConfig.useSpeedPotion)
	{
		movementSpeed.setBaseValue(ModConfig.speedMultiplicator);
	}
}
 
开发者ID:a1lic,项目名称:McMod-CheatStar,代码行数:41,代码来源:EventItemSuperStar.java

示例4: onItemRightClick

import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player){
	int lunchCarried=MAX_FOOD_CARRIED-stack.getItemDamage();
	
	FoodStats stats=player.getFoodStats();
	int playerHunger=20-stats.getFoodLevel();
	
	//feed the player until either they are full or the luncher is out of food
	int toFeedToPlayer=Math.min(lunchCarried, playerHunger);
	
	if(toFeedToPlayer>0){ //if player is hungry and luncher isn't empty
		w.playSoundAtEntity(player, "random.burp", 0.5F, w.rand.nextFloat() * 0.1F + 0.9F);
		stats.addStats(toFeedToPlayer, 0);
		stack.setItemDamage(stack.getItemDamage()+toFeedToPlayer);
		//Debug.dbg("Luncher omnomnomnom! Ate "+toFeedToPlayer);
	}else{
		int foodGathered=0;
		boolean full=false;
		for(int i=0; i<player.inventory.mainInventory.length; i++){
			ItemStack stk=player.inventory.mainInventory[i];
			if(stk!=null && stk.getItem() instanceof ItemFood){ //check if food
				ItemFood item=(ItemFood) stk.getItem();
				int foodPerItem=item.func_150905_g(stk);
				int numberCanConsume=(int) Math.floor( (double)stack.getItemDamage() /foodPerItem );
				int eating=stack.getItemDamage()-foodPerItem*Math.min(numberCanConsume, stk.stackSize);
				//Debug.dbg("Can eat "+numberCanConsume + " of " + stk.stackSize +". Eating "+eating );
				stack.setItemDamage(Math.max(eating,0));
				if(numberCanConsume>=stk.stackSize){
					player.inventory.mainInventory[i]=null;
				}else{
					stk.stackSize-=numberCanConsume;
				}
			}
			if(full)break;
		}
	}
	return stack;
}
 
开发者ID:planetguy32,项目名称:Gizmos,代码行数:39,代码来源:ItemLuncher.java

示例5: setFoodData

import net.minecraft.util.FoodStats; //导入方法依赖的package包/类
private void setFoodData (FoodStats foodStats, int foodLevel, float saturationLevel) {
    foodStats.addStats(1, (saturationLevel - foodStats.getSaturationLevel()) / 2);
    foodStats.addStats(foodLevel - foodStats.getFoodLevel(), 0);
}
 
开发者ID:jaquadro,项目名称:ForgeMods,代码行数:5,代码来源:ExtendedPlayer.java


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