Documentation
¶
Index ¶
- Variables
- func CompareTags(a, b Tag, partial bool) bool
- func StructureToSnbt(tag *CompoundTag) (string, error)
- func ToCompactSNBT(tag Tag) string
- func ToPrettySNBT(tag Tag) string
- func Write(w io.Writer, nbt NamedTag) error
- func WriteCompressed(w io.Writer, nbt NamedTag) error
- type ByteArrayTag
- type ByteTag
- type CompoundTag
- func (t *CompoundTag) Copy() Tag
- func (t *CompoundTag) Get(key string) (Tag, bool)
- func (t *CompoundTag) GetCompound(key string) (*CompoundTag, bool)
- func (t *CompoundTag) GetInt(key string) (int32, bool)
- func (t *CompoundTag) GetList(key string) (*ListTag, bool)
- func (t *CompoundTag) GetString(key string) (string, bool)
- func (t *CompoundTag) ID() TagID
- func (t *CompoundTag) Put(key string, tag Tag)
- func (t *CompoundTag) String() string
- type DoubleTag
- type EndTag
- type FloatTag
- type IntArrayTag
- type IntTag
- type ListTag
- type LongArrayTag
- type LongTag
- type NamedTag
- type Printer
- type ShortTag
- type StringTag
- type Tag
- type TagID
Constants ¶
This section is empty.
Variables ¶
var TagTypeNames = map[TagID]string{ TagEnd: "TAG_End", TagByte: "TAG_Byte", TagShort: "TAG_Short", TagInt: "TAG_Int", TagLong: "TAG_Long", TagFloat: "TAG_Float", TagDouble: "TAG_Double", TagByteArray: "TAG_Byte_Array", TagString: "TAG_String", TagList: "TAG_List", TagCompound: "TAG_Compound", TagIntArray: "TAG_Int_Array", TagLongArray: "TAG_Long_Array", }
TagTypeNames maps TagIDs to their string representations.
Functions ¶
func CompareTags ¶
CompareTags compares two NBT tags for equality. If partial is true, it checks if `a` is a subset of `b`. This version is more explicit and avoids reflect.DeepEqual pitfalls.
func StructureToSnbt ¶
func StructureToSnbt(tag *CompoundTag) (string, error)
StructureToSnbt converts a structure CompoundTag to its SNBT representation, applying the special packing rules from NbtUtils.
func ToCompactSNBT ¶
ToCompactSNBT converts a tag to its compact SNBT representation.
func ToPrettySNBT ¶
ToPrettySNBT converts a tag to its pretty-printed SNBT representation.
Types ¶
type ByteArrayTag ¶
type ByteArrayTag struct{ Value []int8 }
func (*ByteArrayTag) Copy ¶
func (t *ByteArrayTag) Copy() Tag
func (*ByteArrayTag) ID ¶
func (t *ByteArrayTag) ID() TagID
func (*ByteArrayTag) String ¶
func (t *ByteArrayTag) String() string
type CompoundTag ¶
func NewCompoundTag ¶
func NewCompoundTag() *CompoundTag
func ParseSNBT ¶
func ParseSNBT(data string) (*CompoundTag, error)
ParseSNBT converts an SNBT string into a Tag. It expects a CompoundTag.
func SnbtToStructure ¶
func SnbtToStructure(snbt string) (*CompoundTag, error)
SnbtToStructure converts an SNBT string back into a structure CompoundTag, applying the special unpacking rules.
func (*CompoundTag) Copy ¶
func (t *CompoundTag) Copy() Tag
func (*CompoundTag) GetCompound ¶
func (t *CompoundTag) GetCompound(key string) (*CompoundTag, bool)
func (*CompoundTag) ID ¶
func (t *CompoundTag) ID() TagID
func (*CompoundTag) Put ¶
func (t *CompoundTag) Put(key string, tag Tag)
func (*CompoundTag) String ¶
func (t *CompoundTag) String() string
type IntArrayTag ¶
type IntArrayTag struct{ Value []int32 }
func (*IntArrayTag) Copy ¶
func (t *IntArrayTag) Copy() Tag
func (*IntArrayTag) ID ¶
func (t *IntArrayTag) ID() TagID
func (*IntArrayTag) String ¶
func (t *IntArrayTag) String() string
type LongArrayTag ¶
type LongArrayTag struct{ Value []int64 }
func (*LongArrayTag) Copy ¶
func (t *LongArrayTag) Copy() Tag
func (*LongArrayTag) ID ¶
func (t *LongArrayTag) ID() TagID
func (*LongArrayTag) String ¶
func (t *LongArrayTag) String() string
type NamedTag ¶
NamedTag represents a tag with a name, used as the root of an NBT file.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer converts an NBT Tag to its SNBT string representation.
func NewCompactPrinter ¶
func NewCompactPrinter() *Printer
NewCompactPrinter creates a new SNBT printer for compact, single-line output.
func NewPrettyPrinter ¶
NewPrettyPrinter creates a new SNBT printer for formatted, human-readable output.