All block states' properties are parsed and all enums represented as byte
This commit is contained in:
@ -1,14 +1,8 @@
|
||||
package block
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
import "strconv"
|
||||
|
||||
type (
|
||||
Boolean bool
|
||||
Direction string
|
||||
Integer int
|
||||
)
|
||||
type Boolean bool
|
||||
|
||||
func (b Boolean) MarshalText() (text []byte, err error) {
|
||||
return []byte(strconv.FormatBool(bool(b))), nil
|
||||
@ -19,14 +13,7 @@ func (b *Boolean) UnmarshalText(text []byte) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (d Direction) MarshalText() (text []byte, err error) {
|
||||
return []byte(d), nil
|
||||
}
|
||||
|
||||
func (d *Direction) UnmarshalText(text []byte) error {
|
||||
*d = Direction(text)
|
||||
return nil
|
||||
}
|
||||
type Integer int
|
||||
|
||||
func (i Integer) MarshalText() (text []byte, err error) {
|
||||
return []byte(strconv.Itoa(int(i))), nil
|
||||
@ -36,3 +23,34 @@ func (i *Integer) UnmarshalText(text []byte) (err error) {
|
||||
*((*int)(i)), err = strconv.Atoi(string(text))
|
||||
return
|
||||
}
|
||||
|
||||
func (f FrontAndTop) Directions() (front, top Direction) {
|
||||
switch f {
|
||||
case DownEast:
|
||||
return Down, East
|
||||
case DownNorth:
|
||||
return Down, North
|
||||
case DownSouth:
|
||||
return Down, South
|
||||
case DownWest:
|
||||
return Down, West
|
||||
case UpEast:
|
||||
return Up, East
|
||||
case UpNorth:
|
||||
return Up, North
|
||||
case UpSouth:
|
||||
return Up, South
|
||||
case UpWest:
|
||||
return Up, West
|
||||
case WestUp:
|
||||
return West, Up
|
||||
case EastUp:
|
||||
return East, Up
|
||||
case NorthUp:
|
||||
return North, Up
|
||||
case SouthUp:
|
||||
return South, Up
|
||||
default:
|
||||
panic("invalid FrontAndTop")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user