github.com/df-mc/dragonfly@v0.9.13/server/entity/living.go (about) 1 package entity 2 3 import ( 4 "github.com/df-mc/dragonfly/server/entity/effect" 5 "github.com/df-mc/dragonfly/server/world" 6 "github.com/go-gl/mathgl/mgl64" 7 ) 8 9 // Living represents an entity that is alive and that has health. It is able to take damage and will die upon 10 // taking fatal damage. 11 type Living interface { 12 world.Entity 13 // Health returns the health of the entity. 14 Health() float64 15 // MaxHealth returns the maximum health of the entity. 16 MaxHealth() float64 17 // SetMaxHealth changes the maximum health of the entity to the value passed. 18 SetMaxHealth(v float64) 19 // Dead checks if the entity is considered dead. True is returned if the health of the entity is equal to or 20 // lower than 0. 21 Dead() bool 22 // AttackImmune checks if the entity is currently immune to entity attacks. Entities typically turn 23 // immune for half a second after being attacked. 24 AttackImmune() bool 25 // Hurt hurts the entity for a given amount of damage. The source passed represents the cause of the 26 // damage, for example AttackDamageSource if the entity is attacked by another entity. 27 // If the final damage exceeds the health that the entity currently has, the entity is killed. 28 // Hurt returns the final amount of damage dealt to the Living entity and returns whether the Living entity 29 // was vulnerable to the damage at all. 30 Hurt(damage float64, src world.DamageSource) (n float64, vulnerable bool) 31 // Heal heals the entity for a given amount of health. The source passed represents the cause of the 32 // healing, for example FoodHealingSource if the entity healed by having a full food bar. If the health 33 // added to the original health exceeds the entity's max health, Heal may not add the full amount. 34 Heal(health float64, src world.HealingSource) 35 // KnockBack knocks the entity back with a given force and height. A source is passed which indicates the 36 // source of the velocity, typically the position of an attacking entity. The source is used to calculate 37 // the direction which the entity should be knocked back in. 38 KnockBack(src mgl64.Vec3, force, height float64) 39 // Velocity returns the players current velocity. 40 Velocity() mgl64.Vec3 41 // SetVelocity updates the entity's velocity. 42 SetVelocity(velocity mgl64.Vec3) 43 // AddEffect adds an entity.Effect to the entity. If the effect is instant, it is applied to the entity 44 // immediately. If not, the effect is applied to the entity every time the Tick method is called. 45 // AddEffect will overwrite any effects present if the level of the effect is higher than the existing one, or 46 // if the effects' levels are equal and the new effect has a longer duration. 47 AddEffect(e effect.Effect) 48 // RemoveEffect removes any effect that might currently be active on the entity. 49 RemoveEffect(e effect.Type) 50 // Effects returns any effect currently applied to the entity. The returned effects are guaranteed not to have 51 // expired when returned. 52 Effects() []effect.Effect 53 // Speed returns the current speed of the living entity. The default value is different for each entity. 54 Speed() float64 55 // SetSpeed sets the speed of an entity to a new value. 56 SetSpeed(float64) 57 }