/// <summary> /// Handles the food game logic. /// </summary> public virtual void OnUpdate(EntityPlayer par1EntityPlayer) { int i = par1EntityPlayer.WorldObj.DifficultySetting; PrevFoodLevel = FoodLevel; if (FoodExhaustionLevel > 4F) { FoodExhaustionLevel -= 4F; if (FoodSaturationLevel > 0.0F) { FoodSaturationLevel = Math.Max(FoodSaturationLevel - 1.0F, 0.0F); } else if (i > 0) { FoodLevel = Math.Max(FoodLevel - 1, 0); } } if (FoodLevel >= 18 && par1EntityPlayer.ShouldHeal()) { FoodTimer++; if (FoodTimer >= 80) { par1EntityPlayer.Heal(1); FoodTimer = 0; } } else if (FoodLevel <= 0) { FoodTimer++; if (FoodTimer >= 80) { if (par1EntityPlayer.GetHealth() > 10 || i >= 3 || par1EntityPlayer.GetHealth() > 1 && i >= 2) { par1EntityPlayer.AttackEntityFrom(DamageSource.Starve, 1); } FoodTimer = 0; } } else { FoodTimer = 0; } }
/// <summary> /// Called by a player entity when they collide with an entity /// </summary> public override void OnCollideWithPlayer(EntityPlayer par1EntityPlayer) { if (Func_40137_ah()) { int i = GetSlimeSize(); if (CanEntityBeSeen(par1EntityPlayer) && (double)GetDistanceToEntity(par1EntityPlayer) < 0.59999999999999998D * (double)i && par1EntityPlayer.AttackEntityFrom(DamageSource.CauseMobDamage(this), Func_40130_ai())) { WorldObj.PlaySoundAtEntity(this, "mob.slimeattack", 1.0F, (Rand.NextFloat() - Rand.NextFloat()) * 0.2F + 1.0F); } } }