github.com/df-mc/dragonfly@v0.9.13/server/block/model/door.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  // Door is a model used for doors. It has no solid faces and a bounding box that changes depending on
     9  // the direction of the door, whether it is open, and the side of its hinge.
    10  type Door struct {
    11  	// Facing is the direction that the door is facing when closed.
    12  	Facing cube.Direction
    13  	// Open specifies if the Door is open. The direction it opens towards depends on the Right field.
    14  	Open bool
    15  	// Right specifies the attachment side of the door and, with that, the direction it opens in.
    16  	Right bool
    17  }
    18  
    19  // BBox returns a physics.BBox that depends on if the Door is open, what direction it is facing and whether it is
    20  // attached to the right/left side of a block.
    21  func (d Door) BBox(cube.Pos, *world.World) []cube.BBox {
    22  	if d.Open {
    23  		if d.Right {
    24  			return []cube.BBox{full.ExtendTowards(d.Facing.RotateLeft().Face(), -0.8125)}
    25  		}
    26  		return []cube.BBox{full.ExtendTowards(d.Facing.RotateRight().Face(), -0.8125)}
    27  	}
    28  	return []cube.BBox{full.ExtendTowards(d.Facing.Face(), -0.8125)}
    29  }
    30  
    31  // FaceSolid always returns false.
    32  func (d Door) FaceSolid(cube.Pos, cube.Face, *world.World) bool {
    33  	return false
    34  }