本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.canEat方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.canEat方法的具体用法?Java EntityPlayer.canEat怎么用?Java EntityPlayer.canEat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.canEat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eatCake
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.canEat(false))
{
player.triggerAchievement(StatList.field_181724_H);
player.getFoodStats().addStats(2, 0.1F);
int i = ((Integer)state.getValue(BITES)).intValue();
if (i < 6)
{
worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
}
else
{
worldIn.setBlockToAir(pos);
}
}
}
示例2: eatCake
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private boolean eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (!player.canEat(false))
{
return false;
}
else
{
player.addStat(StatList.CAKE_SLICES_EATEN);
player.getFoodStats().addStats(2, 0.1F);
int i = ((Integer)state.getValue(BITES)).intValue();
if (i < 6)
{
worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
}
else
{
worldIn.setBlockToAir(pos);
}
return true;
}
}
示例3: eatCake
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.canEat(false))
{
player.addStat(StatList.CAKE_SLICES_EATEN);
player.getFoodStats().addStats(2, 0.1F);
int i = ((Integer)state.getValue(BITES)).intValue();
if (i < 6)
{
worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
}
else
{
worldIn.setBlockToAir(pos);
}
}
}
示例4: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (playerIn.canEat(this.alwaysEdible))
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
}
return itemStackIn;
}
示例5: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
if (playerIn.canEat(getStats(itemstack).isAlwaysEdible())) {
playerIn.setActiveHand(handIn);
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
else
return new ActionResult<>(EnumActionResult.FAIL, itemstack);
}
示例6: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack stack = playerIn.getHeldItem(handIn);
if (playerIn.canEat(content.alwaysEdible.get(stack.getMetadata()).orElse(false)))
{
playerIn.setActiveHand(handIn);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} else
{
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
}
示例7: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (worldIn.canEat(this.alwaysEdible))
{
worldIn.setActiveHand(playerIn);
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemstack);
}
}
示例8: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (playerIn.canEat(this.alwaysEdible))
{
playerIn.setActiveHand(hand);
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
}
}