github.com/df-mc/dragonfly@v0.9.13/server/entity/direction.go (about) 1 package entity 2 3 import ( 4 "github.com/df-mc/dragonfly/server/world" 5 "github.com/go-gl/mathgl/mgl64" 6 ) 7 8 // Eyed represents an entity that has eyes. 9 type Eyed interface { 10 // EyeHeight returns the offset from their base position that the eyes of an entity are found at. 11 EyeHeight() float64 12 } 13 14 // EyePosition returns the position of the eyes of the entity if the entity implements entity.Eyed, or the 15 // actual position if it doesn't. 16 func EyePosition(e world.Entity) mgl64.Vec3 { 17 pos := e.Position() 18 if eyed, ok := e.(Eyed); ok { 19 pos[1] += eyed.EyeHeight() 20 } 21 return pos 22 }