package
1.16.5-pre2-Vac
Repository: https://github.com/vacplusplus/go-mc.git
Documentation: pkg.go.dev

# README

NBT Go Reference

This package implement the Named Binary Tag format of Minecraft.

The API is very similar to the standard library encoding/json. If you (high probability) have used that, it is easy to use this.

Basic Usage

I don't know why Marshal looks like that, and I will change it to func Marshal(v interface{}) ([]byte, error). Use Encoder is recommended now.

For the following NBT tag:

TAG_Compound("hello world") {
    TAG_String("name"): "Bananrama"
}   

To read and write would look like:

package main

import "bytes"
import "github.com/VacPlusPlus/go-mc/nbt"

type Compound struct {
    Name string `nbt:"name"` // The field must be started with the capital letter
}

func main() {
    var out bytes.Buffer
    banana := Compound{Name: "Bananrama"}
    _ = nbt.Marshal(&out, banana)

    var rama Compound
    _ = nbt.Unmarshal(out.Bytes(), &rama)
}

Struct field tags

There are two tags supported:

  • nbt
  • nbt_type

The nbt tag is used to change the name of the NBT Tag field, whereas the nbt_type tag is used to enforce a certain NBT Tag type when it is ambiguous.

For example:

type Compound struct {
    LongArray []int64
    LongList []int64 `nbt_type:"list"` // forces a long list instead of a long array
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.
Tag type IDs.

# Variables

ErrEND error will be returned when reading a NBT with only Tag_End.

# Structs

No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author