Пример #1
0
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (par3EntityPlayer.capabilities.isCreativeMode
        || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex)) {
      par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
    }

    return par1ItemStack;
  }
  /**
   * sets the itemInUse when the use item button is clicked. Args: itemstack, int maxItemUseDuration
   */
  public void setItemInUse(ItemStack p_71008_1_, int p_71008_2_) {
    super.setItemInUse(p_71008_1_, p_71008_2_);

    if (p_71008_1_ != null
        && p_71008_1_.getItem() != null
        && p_71008_1_.getItem().getItemUseAction(p_71008_1_) == EnumAction.eat) {
      this.getServerForPlayer()
          .getEntityTracker()
          .func_151248_b(this, new S0BPacketAnimation(this, 3));
    }
  }