Squashed below commits
nbt chat message fixes some bug chunk temp relocate module items id
This commit is contained in:
@ -387,7 +387,7 @@ func (d *Decoder) unmarshal(val reflect.Value, tagType byte) error {
|
||||
// Fall back to linear search.
|
||||
for i := range fields.list {
|
||||
ff := &fields.list[i]
|
||||
if strings.EqualFold(ff.name, tn) {
|
||||
if strings.EqualFold(ff.name, tn) || ff.asDefault && tn == "" {
|
||||
f = ff
|
||||
break
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
func (v *Value) UnmarshalNBT(tagType byte, r nbt.DecoderReader) error {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
_ "embed"
|
||||
"testing"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
//go:embed bigTest_test.snbt
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
func (v *Value) TagType() byte { return v.tag }
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
func TestValue_new(t *testing.T) {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
type Value struct {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dynbt
|
||||
|
||||
import "github.com/Tnze/go-mc/nbt"
|
||||
import "git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
|
||||
func (v *Value) Set(key string, val *Value) {
|
||||
if v.tag != nbt.TagCompound {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/Tnze/go-mc/nbt"
|
||||
"git.konjactw.dev/falloutBot/go-mc/nbt"
|
||||
)
|
||||
|
||||
func ExampleMarshal_anonymousStructField() {
|
||||
|
@ -19,6 +19,7 @@ type field struct {
|
||||
index []int
|
||||
typ reflect.Type
|
||||
omitEmpty bool
|
||||
asDefault bool
|
||||
asList bool
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ func typeFields(t reflect.Type) (tInfo structFields) {
|
||||
}
|
||||
|
||||
// parse options
|
||||
var omitEmpty, asList bool
|
||||
var omitEmpty, asList, asDefault bool
|
||||
for opts != "" {
|
||||
var name string
|
||||
name, opts, _ = strings.Cut(opts, ",")
|
||||
@ -114,6 +115,8 @@ func typeFields(t reflect.Type) (tInfo structFields) {
|
||||
omitEmpty = true
|
||||
case "list":
|
||||
asList = true
|
||||
case "default":
|
||||
asDefault = true
|
||||
}
|
||||
}
|
||||
// Deprecated: use `nbt:",list"` instead.
|
||||
@ -133,6 +136,7 @@ func typeFields(t reflect.Type) (tInfo structFields) {
|
||||
index: index,
|
||||
typ: ft,
|
||||
omitEmpty: omitEmpty,
|
||||
asDefault: asDefault,
|
||||
asList: asList,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user