dynbt

package
v764.0.0-...-0e72a48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compound

type Compound struct {
	// contains filtered or unexported fields
}

func (*Compound) Get

func (c *Compound) Get(key string) *Value

func (*Compound) Len

func (c *Compound) Len() int

func (*Compound) Set

func (c *Compound) Set(key string, val *Value)

type Value

type Value struct {
	// contains filtered or unexported fields
}

func NewBoolean

func NewBoolean(v bool) *Value

func NewByte

func NewByte(v int8) *Value

func NewByteArray

func NewByteArray(v []byte) *Value

func NewCompound

func NewCompound() *Value

func NewDouble

func NewDouble(d float64) *Value

func NewFloat

func NewFloat(f float32) *Value

func NewInt

func NewInt(v int32) *Value

func NewIntArray

func NewIntArray(v []int32) *Value

func NewList

func NewList(elems ...*Value) *Value

func NewLong

func NewLong(v int64) *Value

func NewLongArray

func NewLongArray(v []int64) *Value

func NewShort

func NewShort(v int16) *Value

func NewString

func NewString(str string) *Value

func (*Value) Boolean

func (v *Value) Boolean() bool

func (*Value) Byte

func (v *Value) Byte() int8

func (*Value) ByteArray

func (v *Value) ByteArray() []byte

func (*Value) Compound

func (v *Value) Compound() *Compound

func (*Value) Double

func (v *Value) Double() float64

func (*Value) Float

func (v *Value) Float() float32

func (*Value) Get

func (v *Value) Get(keys ...string) *Value

func (*Value) Int

func (v *Value) Int() int32

func (*Value) IntArray

func (v *Value) IntArray() []int32

func (*Value) List

func (v *Value) List() []*Value

func (*Value) Long

func (v *Value) Long() int64

func (*Value) LongArray

func (v *Value) LongArray() []int64

func (*Value) MarshalNBT

func (v *Value) MarshalNBT(w io.Writer) (err error)

func (*Value) Set

func (v *Value) Set(key string, val *Value)

func (*Value) Short

func (v *Value) Short() int16

func (*Value) String

func (v *Value) String() string

func (*Value) TagType

func (v *Value) TagType() byte

func (*Value) UnmarshalNBT

func (v *Value) UnmarshalNBT(tagType byte, r nbt.DecoderReader) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL