Overview of the erl_nbt library

Copyright © 2021 hypothermic.nl

Version: 1.0.0

Authors: Matthijs Bakker (matthijs at hypothermic .nl).

erl_nbt is a library which can manipulate NBT (Named Binary Tag) data.

It can decode binary NBT data to an Erlang Map. It can encode data in an Erlang Map to binary NBT data.

Examples of how to use the library can be found under the test directory, or on the documentation page usage.edoc

The mapping of NBT types to Erlang types can be found below:

NBT Type Description Erlang Type
Byte 8-bit signed integer erlang:integer()
Short 16-bit signed integer erlang:integer()
Int 32-bit signed integer erlang:integer()
Long 64-bit signed integer erlang:integer()
Float 32-bit signed float erlang:float()
Double 64-bit signed float erlang:float()
String List of characters erlang:string()

The following options can be passed to erl_nbt:decode/2 and/or erl_nbt:encode/2:

Option Value Type Description
?OPTION_COMPRESSION erl_nbt:compression() Instructs the encoder/decoder to force the usage of a particular kind of compression.
?OPTION_MAX_DEPTH integer() Sets the maximum depth of nested compound tags that will be read. This value defaults to ?DEFAULT_MAX_DEPTH
?OPTION_MAX_CHILDREN integer() Sets the maximum amount of children that will be read from a compound tag. This value defaults to ?DEFAULT_MAX_CHILDREN
?OPTION_RETURN_REMAINDER - Instructs the decoder to return any bytes that follow the first NBT tag. Does not have any use in 'erl_nbt:encode/2'.

Minimal example:

        EncodedBinary = erl_nbt:encode(#{"player" => #{"name" => {?TAG_STRING_TYPE, "Bananrama"}}}),

        DecodedNbt = erl_nbt:decode(EncodedBinary),
    

Version history:

Version Tag Notes
0.1.0 Initial Release
0.2.0 Improved Erlang data structure representation, support for typed array tags
1.0.0 Support for typed lists, let user give encoder/decoder options, solidify API

Generated by EDoc