github.com/df-mc/dragonfly@v0.9.13/server/block/wall_connection_type.go (about) 1 package block 2 3 // WallConnectionType represents the connection type of a wall. 4 type WallConnectionType struct { 5 wallConnectionType 6 } 7 8 // NoWallConnection returns the no connection type of a wall. 9 func NoWallConnection() WallConnectionType { 10 return WallConnectionType{0} 11 } 12 13 // ShortWallConnection returns the short connection type of a wall. 14 func ShortWallConnection() WallConnectionType { 15 return WallConnectionType{1} 16 } 17 18 // TallWallConnection returns the tall connection type of a wall. 19 func TallWallConnection() WallConnectionType { 20 return WallConnectionType{2} 21 } 22 23 // WallConnectionTypes returns a list of all wall connection types. 24 func WallConnectionTypes() []WallConnectionType { 25 return []WallConnectionType{NoWallConnection(), ShortWallConnection(), TallWallConnection()} 26 } 27 28 type wallConnectionType uint8 29 30 // Uint8 returns the wall connection as a uint8. 31 func (w wallConnectionType) Uint8() uint8 { 32 return uint8(w) 33 } 34 35 // String ... 36 func (w wallConnectionType) String() string { 37 switch w { 38 case 0: 39 return "none" 40 case 1: 41 return "short" 42 case 2: 43 return "tall" 44 } 45 panic("unknown wall connection type") 46 } 47 48 // Height returns the height of the connection for the block model. 49 func (w wallConnectionType) Height() float64 { 50 switch w { 51 case 0: 52 return 0 53 case 1: 54 return 0.75 55 case 2: 56 return 1 57 } 58 panic("unknown wall connection type") 59 }