Documentation ¶
Overview ¶
Package dynbt is a library that provides dynamic NBT operation APIs.
Dynamically represented NBT value is useful in many cases, for example,
- You want to store custom structural values at runtime.
- You want to query or modify the data later. (Otherwise use the nbt.RawMessage)
- You don't know what type the data is at compile time. (Otherwise use the nbt.RawMessage too)
The *Value provides a group of APIs on top of the nbt package. *Value implements nbt.Marshaler and nbt.Unmarshaler interfaces. It can be used as a field of struct, or element of slice, map, etc. The pointer type should always be used, unless used as fields for structures
Notice that querying Tags in Compound use a linear search, so it's not recommended to use it in a large Compound. The better choice is map[string]*Value for dynamic accessing a large Compound.
This package tries its best to not copy data if possible. It returns the underlying data in some cases. Don't modify them!
Index ¶
- type Compound
- type Value
- func NewBoolean(v bool) *Value
- func NewByte(v int8) *Value
- func NewByteArray(v []byte) *Value
- func NewCompound() *Value
- func NewDouble(d float64) *Value
- func NewFloat(f float32) *Value
- func NewInt(v int32) *Value
- func NewIntArray(v []int32) *Value
- func NewList(elems ...*Value) *Value
- func NewLong(v int64) *Value
- func NewLongArray(v []int64) *Value
- func NewShort(v int16) *Value
- func NewString(str string) *Value
- func (v *Value) Boolean() bool
- func (v *Value) Byte() int8
- func (v *Value) ByteArray() []byte
- func (v *Value) Compound() *Compound
- func (v *Value) Double() float64
- func (v *Value) Float() float32
- func (v *Value) Get(keys ...string) *Value
- func (v *Value) Int() int32
- func (v *Value) IntArray() []int32
- func (v *Value) List() []*Value
- func (v *Value) Long() int64
- func (v *Value) LongArray() []int64
- func (v *Value) MarshalNBT(w io.Writer) (err error)
- func (v *Value) Set(key string, val *Value)
- func (v *Value) Short() int16
- func (v *Value) String() string
- func (v *Value) TagType() byte
- func (v *Value) UnmarshalNBT(tagType byte, r nbt.DecoderReader) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func NewBoolean ¶
func NewByteArray ¶
func NewCompound ¶
func NewCompound() *Value
func NewIntArray ¶
func NewLongArray ¶
func (*Value) UnmarshalNBT ¶
func (v *Value) UnmarshalNBT(tagType byte, r nbt.DecoderReader) error