Ejemplo n.º 1
0
 /// <summary>
 /// Eat some food.
 /// </summary>
 public virtual void AddStats(ItemFood par1ItemFood)
 {
     AddStats(par1ItemFood.GetHealAmount(), par1ItemFood.GetSaturationModifier());
 }
Ejemplo n.º 2
0
        /// <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));
        }