本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getFoodStats方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getFoodStats方法的具体用法?Java EntityPlayer.getFoodStats怎么用?Java EntityPlayer.getFoodStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.getFoodStats方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExhaustion
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static float getExhaustion(EntityPlayer of)
{
FoodStats stats = of.getFoodStats();
if (!foodExhaustionLevelFld.isAccessible())
{
foodExhaustionLevelFld.setAccessible(true);
}
try
{
return foodExhaustionLevelFld.getFloat(stats);
}
catch (Exception ex)
{
FMLCommonHandler.instance().raiseException(ex, "ExPetrum was unable to reflect player's FoodStats!", true);
return -1;
}
}
示例2: setExhaustion
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SuppressWarnings("SameParameterValue")
public static void setExhaustion(EntityPlayer of, float f)
{
FoodStats stats = of.getFoodStats();
if (!foodExhaustionLevelFld.isAccessible())
{
foodExhaustionLevelFld.setAccessible(true);
}
try
{
foodExhaustionLevelFld.setFloat(stats, f);
}
catch (Exception ex)
{
FMLCommonHandler.instance().raiseException(ex, "ExPetrum was unable to reflect player's FoodStats!", true);
}
}
示例3: onFoodEaten
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound()); //not really supposed to happen ingame since you only get the stews with NBT values assigned but it prevents crashing
}
final FoodStats foodStats = player.getFoodStats();
foodStats.setFoodLevel(foodStats.getFoodLevel() + stack.getTagCompound().getInteger("hunger"));
foodStats.setFoodSaturationLevel(foodStats.getFoodLevel() + stack.getTagCompound().getFloat("saturation"));
player.addItemStackToInventory(new ItemStack(Items.BOWL, 1));
}