/// <summary> /// Called when the entity is attacked. /// </summary> public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2) { Entity entity = par1DamageSource.GetEntity(); AiSit.Func_48407_a(false); if (entity != null && !(entity is EntityPlayer) && !(entity is EntityArrow)) { par2 = (par2 + 1) / 2; } return(base.AttackEntityFrom(par1DamageSource, par2)); }
/// <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)); }
/// <summary> /// Called when the entity is attacked. /// </summary> public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2) { AiSit.Func_48407_a(false); return(base.AttackEntityFrom(par1DamageSource, par2)); }
/// <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 (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.Next(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, (sbyte)7); } else { Func_48142_a(false); WorldObj.SetEntityState(this, (sbyte)6); } } return(true); } } else { if (itemstack != null && (Item.ItemsList[itemstack.ItemID] is 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.ToUpper() == GetOwnerName().ToUpper() && !WorldObj.IsRemote && !IsWheat(itemstack)) { AiSit.Func_48407_a(!IsSitting()); IsJumping = false; SetPathToEntity(null); } } return(base.Interact(par1EntityPlayer)); }