github.com/df-mc/dragonfly@v0.9.13/server/block/model/cocoa_bean.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  )
     7  
     8  // CocoaBean is a model used by cocoa bean blocks.
     9  type CocoaBean struct {
    10  	// Facing is the face that the cocoa bean faces. It is the opposite of the face that the CocoaBean is attached to.
    11  	Facing cube.Direction
    12  	// Age is the age of the CocoaBean. The age influences the size of the CocoaBean. The maximum age value of a cocoa
    13  	// bean is 3.
    14  	Age int
    15  }
    16  
    17  // BBox returns a single physics.BBox whose size depends on the age of the CocoaBean.
    18  func (c CocoaBean) BBox(cube.Pos, *world.World) []cube.BBox {
    19  	return []cube.BBox{full.
    20  		Stretch(c.Facing.RotateRight().Face().Axis(), -(6-float64(c.Age))/16).
    21  		ExtendTowards(cube.FaceDown, -0.25).
    22  		ExtendTowards(cube.FaceUp, -((7-float64(c.Age)*2)/16)).
    23  		ExtendTowards(c.Facing.Face(), -0.0625).
    24  		ExtendTowards(c.Facing.Opposite().Face(), -((11 - float64(c.Age)*2) / 16))}
    25  }
    26  
    27  // FaceSolid always returns false.
    28  func (c CocoaBean) FaceSolid(cube.Pos, cube.Face, *world.World) bool {
    29  	return false
    30  }