github.com/df-mc/dragonfly@v0.9.13/server/block/model/wall.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 // Wall is a model used by all wall types. 9 type Wall struct { 10 // NorthConnection is the height of the connection for the north direction. 11 NorthConnection float64 12 // EastConnection is the height of the connection for the east direction. 13 EastConnection float64 14 // SouthConnection is the height of the connection for the south direction. 15 SouthConnection float64 16 // WestConnection is the height of the connection for the west direction. 17 WestConnection float64 18 // Post is if the wall is the full height of a block or not. 19 Post bool 20 } 21 22 // BBox ... 23 func (w Wall) BBox(cube.Pos, *world.World) []cube.BBox { 24 postHeight := 0.8125 25 if w.Post { 26 postHeight = 1 27 } 28 boxes := []cube.BBox{cube.Box(0.25, 0, 0.25, 0.75, postHeight, 0.75)} 29 if w.NorthConnection > 0 { 30 boxes = append(boxes, cube.Box(0.25, 0, 0.75, 0.75, w.SouthConnection, 1)) 31 } 32 if w.EastConnection > 0 { 33 boxes = append(boxes, cube.Box(0, 0, 0.25, 0.25, w.WestConnection, 0.75)) 34 } 35 if w.SouthConnection > 0 { 36 boxes = append(boxes, cube.Box(0.25, 0, 0, 0.75, w.NorthConnection, 0.25)) 37 } 38 if w.WestConnection > 0 { 39 boxes = append(boxes, cube.Box(0.75, 0, 0.25, 1, w.EastConnection, 0.75)) 40 } 41 return boxes 42 } 43 44 // FaceSolid returns true if the face is in the Y axis. 45 func (w Wall) FaceSolid(_ cube.Pos, face cube.Face, _ *world.World) bool { 46 return face.Axis() == cube.Y 47 }