github.com/df-mc/dragonfly@v0.9.13/server/block/model/composter.go (about)

     1  package model
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/block/cube"
     5  	"github.com/df-mc/dragonfly/server/world"
     6  	"math"
     7  )
     8  
     9  // Composter is a model used by composter blocks. It is solid on all sides apart from the top, and the height of the
    10  // inside area depends on the level of compost inside the composter.
    11  type Composter struct {
    12  	// Level is the level of compost inside the composter.
    13  	Level int
    14  }
    15  
    16  // BBox ...
    17  func (c Composter) BBox(_ cube.Pos, _ *world.World) []cube.BBox {
    18  	compostHeight := math.Abs(math.Min(float64(c.Level), 7)*0.125 - 0.0625)
    19  	return []cube.BBox{
    20  		cube.Box(0, 0, 0, 1, 1, 0.125),
    21  		cube.Box(0, 0, 0.875, 1, 1, 1),
    22  		cube.Box(0.875, 0, 0, 1, 1, 1),
    23  		cube.Box(0, 0, 0, 0.125, 1, 1),
    24  		cube.Box(0.125, 0, 0.125, 0.875, 0.125+compostHeight, 0.875),
    25  	}
    26  }
    27  
    28  // FaceSolid returns true for all faces other than the top.
    29  func (Composter) FaceSolid(_ cube.Pos, face cube.Face, _ *world.World) bool {
    30  	return face != cube.FaceUp
    31  }