support block state & nbt improvement
This commit is contained in:
38
level/block/properties.go
Normal file
38
level/block/properties.go
Normal file
@ -0,0 +1,38 @@
|
||||
package block
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
Boolean bool
|
||||
Direction string
|
||||
Integer int
|
||||
)
|
||||
|
||||
func (b Boolean) MarshalText() (text []byte, err error) {
|
||||
return []byte(strconv.FormatBool(bool(b))), nil
|
||||
}
|
||||
|
||||
func (b *Boolean) UnmarshalText(text []byte) (err error) {
|
||||
*((*bool)(b)), err = strconv.ParseBool(string(text))
|
||||
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
|
||||
}
|
||||
|
||||
func (i Integer) MarshalText() (text []byte, err error) {
|
||||
return []byte(strconv.Itoa(int(i))), nil
|
||||
}
|
||||
|
||||
func (i *Integer) UnmarshalText(text []byte) (err error) {
|
||||
*((*int)(i)), err = strconv.Atoi(string(text))
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user