Esempio n. 1
0
 public boolean func_70085_c(EntityPlayer p_70085_1_) {
   ItemStack itemstack = p_70085_1_.field_71071_by.func_70448_g();
   if (func_70909_n()) {
     if (itemstack != null && (Item.field_77698_e[itemstack.field_77993_c] instanceof ItemFood)) {
       ItemFood itemfood = (ItemFood) Item.field_77698_e[itemstack.field_77993_c];
       if (itemfood.func_77845_h() && field_70180_af.func_75679_c(18) < 20) {
         if (!p_70085_1_.field_71075_bZ.field_75098_d) {
           itemstack.field_77994_a--;
         }
         func_70691_i(itemfood.func_77847_f());
         if (itemstack.field_77994_a <= 0) {
           p_70085_1_.field_71071_by.func_70299_a(p_70085_1_.field_71071_by.field_70461_c, null);
         }
         return true;
       }
     }
     if (p_70085_1_.field_71092_bJ.equalsIgnoreCase(func_70905_p())
         && !field_70170_p.field_72995_K
         && !func_70877_b(itemstack)) {
       field_70911_d.func_75270_a(!func_70906_o());
       field_70703_bu = false;
       func_70778_a(null);
     }
   } else if (itemstack != null
       && itemstack.field_77993_c == Item.field_77755_aX.field_77779_bT
       && !func_70919_bu()) {
     if (!p_70085_1_.field_71075_bZ.field_75098_d) {
       itemstack.field_77994_a--;
     }
     if (itemstack.field_77994_a <= 0) {
       p_70085_1_.field_71071_by.func_70299_a(p_70085_1_.field_71071_by.field_70461_c, null);
     }
     if (!field_70170_p.field_72995_K) {
       if (field_70146_Z.nextInt(3) == 0) {
         func_70903_f(true);
         func_70778_a(null);
         func_70624_b(null);
         field_70911_d.func_75270_a(true);
         func_70606_j(20);
         func_70910_a(p_70085_1_.field_71092_bJ);
         func_70908_e(true);
         field_70170_p.func_72960_a(this, (byte) 7);
       } else {
         func_70908_e(false);
         field_70170_p.func_72960_a(this, (byte) 6);
       }
     }
     return true;
   }
   return super.func_70085_c(p_70085_1_);
 }
Esempio n. 2
0
  /**
   * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a
   * pig.
   */
  public boolean interact(EntityPlayer par1EntityPlayer) {
    ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

    if (!isTamed()) {
      if (itemstack != null && itemstack.itemID == Item.bone.shiftedIndex && !isAngry()) {
        if (!par1EntityPlayer.capabilities.isCreativeMode) {
          itemstack.stackSize--;
        }

        if (itemstack.stackSize <= 0) {
          par1EntityPlayer.inventory.setInventorySlotContents(
              par1EntityPlayer.inventory.currentItem, null);
        }

        if (!worldObj.isRemote) {
          if (rand.nextInt(3) == 0) {
            setTamed(true);
            setPathToEntity(null);
            setAttackTarget(null);
            aiSit.func_48407_a(true);
            setEntityHealth(20);
            setOwner(par1EntityPlayer.username);
            func_48142_a(true);
            worldObj.setEntityState(this, (byte) 7);
          } else {
            func_48142_a(false);
            worldObj.setEntityState(this, (byte) 6);
          }
        }

        return true;
      }
    } else {
      if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood)) {
        ItemFood itemfood = (ItemFood) Item.itemsList[itemstack.itemID];

        if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20) {
          if (!par1EntityPlayer.capabilities.isCreativeMode) {
            itemstack.stackSize--;
          }

          heal(itemfood.getHealAmount());

          if (itemstack.stackSize <= 0) {
            par1EntityPlayer.inventory.setInventorySlotContents(
                par1EntityPlayer.inventory.currentItem, null);
          }

          return true;
        }
      }

      if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName())
          && !worldObj.isRemote
          && !isWheat(itemstack)) {
        aiSit.func_48407_a(!isSitting());
        isJumping = false;
        setPathToEntity(null);
      }
    }

    return super.interact(par1EntityPlayer);
  }