Skip to content
Scala libary for manipulating NBT.
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example/scala/com/xorinc/scalanbt/example
project
src/main/scala/com/xorinc/scalanbt
README.md
build.sbt

README.md

ScalaNBT

Scala library for NBT io with some Mojangson support.

Usage

There are ten data tags:

  • Tags for each of the six Java number primitives, byte, short, int, long, float, double, as well as String.
  • A list tag that can hold exactly one type of tag.
  • A compound tag (a map) that maps strings to arbitrary tags.
  • An end tag that exists only to denote a missing tag, and does not exist

General tags can be created with Tag(). If no Tag type exists that can hold the argument TagEnd will be returned.


Primitive tags can be created in one of two ways:

TagString("foo") TagInt(1)

"foo".nbt 1.nbt

These are immutable.


TagLists can be manipulated like Seqs, but types are validated at runtime rather than at compile time.

foo = list(1)

list(2) = 5

TagList will use Tag() to convert non-nbt values into tags.

You can also create TagLists from Traversables:

List(1, 2).nbt


TagCompounds can be manipulated like Maps, but you can use dynamic notation too:

compound.key = "value"

TagCompound will use Tag() to convert non-nbt values into tags.

You can also create them similarly to Maps:

TagCompound("one" -> 1, "2" -> "two")


TagCompounds can be converted to and from binary form via the io.readNBT and io.writeNBT functions, or the .toBytes method.

All tags can be converted to mojangson via the .mojangson method.

You can’t perform that action at this time.