Module erl_nbt

Provides an interface for dealing with NBT data in Erlang.

Copyright © (C) 2021 hypothermic.nl

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

Description

Provides an interface for dealing with NBT data in Erlang

Data Types

compression()

compression() = '?COMPRESSION_UNCOMPRESSED' | '?COMPRESSION_GZIP'

The types of compression that may be used in NBT files according to the official spec

decode_option()

decode_option() = '?OPTION_RETURN_REMAINDER' | {'?OPTION_COMPRESSION', Compression::compression()} | {'?OPTION_MAX_CHILDREN', MaxChildren::integer()} | {'?OPTION_MAX_DEPTH', MaxDepth::integer()}

An option which alters the functionality of the decoding process

decode_options()

decode_options() = [decode_option()]

A list of decode_option()

encode_option()

encode_option() = {'?OPTION_COMPRESSION', Compression::compression()}

An option which alters the functionality of the encoding process

encode_options()

encode_options() = [encode_option()]

A list of encode_option()

nbt()

nbt() = #{nbt_key() => {nbt_type(), nbt_value()}}

A named NBT tag of any type

nbt_byte()

nbt_byte() = byte()

A value which is guaranteed to be a 8-bit signed integer (from -128 to +127)

nbt_byte_array()

nbt_byte_array() = list()

A list of nbt_byte()

nbt_compound()

nbt_compound() = map()

A collection of named tags. The order that these tags are stored in is not guaranteed.

nbt_double()

nbt_double() = float()

A value which is guaranteed to be a double-precision floating point number (NaN possible) Due to the way the Erlang BEAM VM handles IEEE-754 floats, this value can't be SNaN, QNaN, -0/+0 or infinity.

nbt_float()

nbt_float() = float()

A value which is guaranteed to be a single-precision floating point number (NaN possible) Due to the way the Erlang BEAM VM handles IEEE-754 floats, this value can't be SNaN, QNaN, -0/+0 or infinity.

nbt_int()

nbt_int() = integer()

A value which is guaranteed to be a 32-bit signed integer (from -2^31 to (+2^31)-1)

nbt_int_array()

nbt_int_array() = list()

A list of nbt_int()

nbt_key()

nbt_key() = nbt_string()

A string containing the tag name

nbt_long()

nbt_long() = integer()

A value which is guaranteed to be a 64-bit signed integer (from -2^63 to (+2^63)-1)

nbt_long_array()

nbt_long_array() = list()

A list of nbt_long()

nbt_short()

nbt_short() = integer()

A value which is guaranteed to be a 16-bit signed integer (from -32768 to +32767)

nbt_string()

nbt_string() = string()

A string with a maximum length of nbt_short() (unchecked)

nbt_type()

nbt_type() = byte | short | int | long | float | double | byte_array | int_array | long_array | string | compound

An atom describing the type of this tag

nbt_value()

nbt_value() = nbt_byte() | nbt_short() | nbt_int() | nbt_long() | nbt_float() | nbt_double() | nbt_byte_array() | nbt_int_array() | nbt_long_array() | nbt_string() | nbt_compound()

The value of a tag. The type of this value depends on the type of the tag

Function Index

decode/1Decodes the first (nested) NBT tag in the specified binary.
decode/2Decodes the first (nested) NBT tag in the specified binary.
encode/1Encodes an NBT tag in Erlang Map form to binary.
encode/2Encodes an NBT tag in Erlang Map form to binary.

Function Details

decode/1

decode(Binary::binary()) -> {ok, nbt()}

Binary: The binary to read the NBT tag from

returns: A tuple containing {ok, Nbt} where Nbt is a map

Decodes the first (nested) NBT tag in the specified binary.

This function reads the first NBT tag from a binary. If it is a compound tag, it will read all children (including nested compound tags.)

Both uncompressed and GZIP-ped binaries are accepted.

Introduced in: 0.1.0

decode/2

decode(Binary::binary(), Options::decode_options()) -> {ok, nbt()} | {ok, nbt(), Remainder::binary()}

Binary: The binary to read the NBT tag from

returns: A tuple containing {ok, Nbt} where Nbt is a map

Decodes the first (nested) NBT tag in the specified binary.

This function reads the first NBT tag from a binary. If it is a compound tag, it will read all children (including nested compound tags.)

Both uncompressed and GZIP-ped binaries are accepted.

Introduced in: 0.3.0

encode/1

encode(Nbt::nbt()) -> {ok, binary()}

Nbt: The NBT tag to encode

returns: A tuple containing {ok, Nbt} where Nbt is a map

Encodes an NBT tag in Erlang Map form to binary.

This function accepts an NBT tag representation in map-form (aka type erl_nbt:nbt()) and encodes it into a binary.

Introduced in: 0.1.0

encode/2

encode(Nbt::nbt(), Options::encode_options()) -> {ok, binary()}

Nbt: The NBT tag to encode

returns: A tuple containing {ok, Nbt} where Nbt is a map

Encodes an NBT tag in Erlang Map form to binary.

This function accepts an NBT tag representation in map-form (aka type erl_nbt:nbt()) and encodes it into a binary.

Introduced in: 0.3.0


Generated by EDoc