Java Code Examples for net.minecraft.entity.player.EntityPlayer#canEat()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#canEat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockEndCake.java From Ex-Aliquo with MIT License | 6 votes |
private void nomEndCake(World world, int x, int y, int z, EntityPlayer player) { if (player.canEat(false)) { int l = world.getBlockMetadata(x, y, z) + 1; if (l >= 6) { return; } else { player.getFoodStats().addStats(2, 0.1F); world.setBlockMetadataWithNotify(x, y, z, l, 2); if (world.provider.dimensionId == 0) { if (!BlockEndPortal.bossDefeated) player.addPotionEffect(new PotionEffect(Potion.resistance.id, 200, 1)); player.travelToDimension(1); } } } }
Example 2
Source File: DrinkSoymilkRamune.java From TofuCraftReload with MIT License | 5 votes |
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.canEat(true)||playerIn.isCreative()) { playerIn.setActiveHand(handIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } else { return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } }
Example 3
Source File: ItemGrowingTofu.java From TofuCraftReload with MIT License | 5 votes |
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.canEat(false)) { playerIn.setActiveHand(handIn); return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } else { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } }
Example 4
Source File: ItemFood.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@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); } }
Example 5
Source File: ItemPLFood.java From Production-Line with MIT License | 5 votes |
@Nonnull public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (playerIn.canEat(this.alwaysEdible)) { playerIn.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } else { return new ActionResult<>(EnumActionResult.FAIL, stack); } }
Example 6
Source File: ItemFoodTFC.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemStackIn = playerIn.getHeldItem(handIn); if (playerIn.canEat(false)) { playerIn.setActiveHand(handIn); return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); } return new ActionResult(EnumActionResult.FAIL, itemStackIn); }
Example 7
Source File: BlockArcaneCake.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
private void eatCakeSlice(World world, int x, int y, int z, EntityPlayer player) { if (player.canEat(false)) { player.getFoodStats().addStats(2, 1.0F); int l = world.getBlockMetadata(x, y, z) + 1; if (l >= 12) { world.setBlockToAir(x, y, z); } else { world.setBlockMetadataWithNotify(x, y, z, l, 2); } } }