/// <summary> /// Do not make give this method the name canInteractWith because it clashes with Container /// </summary> public virtual bool IsUseableByPlayer(EntityPlayer par1EntityPlayer) { if (IsDead) { return(false); } return(par1EntityPlayer.GetDistanceSqToEntity(this) <= 64D); }
/// <summary> /// Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. /// </summary> public override bool Interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.Inventory.GetCurrentItem(); if (!IsTamed()) { if (AiTempt.Func_48270_h() && itemstack != null && itemstack.ItemID == Item.FishRaw.ShiftedIndex && par1EntityPlayer.GetDistanceSqToEntity(this) < 9D) { itemstack.StackSize--; if (itemstack.StackSize <= 0) { par1EntityPlayer.Inventory.SetInventorySlotContents(par1EntityPlayer.Inventory.CurrentItem, null); } if (!WorldObj.IsRemote) { if (Rand.Next(3) == 0) { SetTamed(true); Func_48147_c(1 + WorldObj.Rand.Next(3)); SetOwner(par1EntityPlayer.Username); Func_48142_a(true); AiSit.Func_48407_a(true); WorldObj.SetEntityState(this, (sbyte)7); } else { Func_48142_a(false); WorldObj.SetEntityState(this, (sbyte)6); } } } return(true); } if (par1EntityPlayer.Username.ToUpper() == GetOwnerName().ToUpper() && !WorldObj.IsRemote && !IsWheat(itemstack)) { AiSit.Func_48407_a(!IsSitting()); } return(base.Interact(par1EntityPlayer)); }