@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); // Copy from superclass with our own check boolean flag = canFire(stack, player); ActionResult<ItemStack> ret = ForgeEventFactory.onArrowNock(stack, world, player, hand, flag); if (ret != null) return ret; if (!player.capabilities.isCreativeMode && !flag) { return new ActionResult<>(EnumActionResult.FAIL, stack); } else { player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }
boolean hasAmmo = !findAmmo(itemStackIn, playerIn).isEmpty(); ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, hand, hasAmmo); if(ret != null) { return ret;
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); boolean flag = this.findAmmo(playerIn) != null; ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, hand, flag); if (ret != null) return ret; if (!playerIn.capabilities.isCreativeMode && !flag) { return !flag ? new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn) : new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn); } else { playerIn.setActiveHand(hand); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); boolean flag = !this.findAmmo(player).isEmpty(); ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(stack, world, player, hand, flag); if (ret != null) { return ret; } if (!player.capabilities.isCreativeMode && !flag) { return !flag ? new ActionResult<>(EnumActionResult.FAIL, stack) : new ActionResult<>(EnumActionResult.PASS, stack); } else { player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }