nbt can encode or decode bool values as TagByte and []bool as TagByteArray now. close #175

This commit is contained in:
Tnze
2022-05-20 13:18:39 +08:00
parent 1ff25ae8ab
commit 588b7872f1
4 changed files with 67 additions and 7 deletions

View File

@ -90,6 +90,8 @@ func (d *Decoder) unmarshal(val reflect.Value, tagType byte) error {
switch vk := val.Kind(); vk {
default:
return errors.New("cannot parse TagByte as " + vk.String())
case reflect.Bool:
val.SetBool(value != 0)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
val.SetInt(int64(value))
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: