github.com/df-mc/dragonfly@v0.9.13/server/player/type.go (about)

     1  package player
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/block/cube"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  )
     7  
     8  // Type is a world.EntityType implementation for Player.
     9  type Type struct{}
    10  
    11  func (Type) EncodeEntity() string   { return "minecraft:player" }
    12  func (Type) NetworkOffset() float64 { return 1.62 }
    13  func (Type) BBox(e world.Entity) cube.BBox {
    14  	p := e.(*Player)
    15  	s := p.Scale()
    16  	switch {
    17  	case p.Sneaking():
    18  		return cube.Box(-0.3*s, 0, -0.3*s, 0.3*s, 1.5*s, 0.3*s)
    19  	case p.Gliding(), p.Swimming():
    20  		return cube.Box(-0.3*s, 0, -0.3*s, 0.3*s, 0.6*s, 0.3*s)
    21  	default:
    22  		return cube.Box(-0.3*s, 0, -0.3*s, 0.3*s, 1.8*s, 0.3*s)
    23  	}
    24  }