NBTフォーマット(The Named Binary Tag format)はマインクラフトでデータをファイルに保存するのに使われる。このフォーマットをNotchが簡潔に説明しているspecification。このフォーマットは様々な"タグ"からなるツリー構造でデータを蓄えている。全てのタグはIDとnameを持っている。The original known version was 19132 as introduced in Minecraft Beta 1.3, and since then has been updated to 19133 with Anvil, with the addition of the Int Array tag.The NBT format dates all the way back to Minecraft Indev with tags 0 to 10 in use.
タグ定義
タグはデータツリーの一部分である。タグの最初のバイトはタグタイプIDである。続いて2バイトがnameの長さで、それからnameがUTF-8フォーマットで続いている(注意: TAG_Endに名前は無いので2バイトは必要ない、名前が空であると仮定されている)。タグnameにもしかしたらスペースがあるかもしれない、だがマインクラフト自身はけっしてnameにスペースを含めタグを保存することはない。最終的にタグのタイプによりタグのペイロードバイトが続く。このテーブルはNBTFormat19133バージョンにおける12のタグの説明である。
ID | Icon | Tag Type | Payload | Description | Storage Capacity |
---|---|---|---|---|---|
0 | TAG_End | なし | 終了するのに使用する。このタグに名前はない、だから1バイト(0)のみである。空のリストのタグになることもある。 | N/A | |
1 | TAG_Byte | 1 byte / 8 bits, signed | 符号付整数型 しばしば真偽値を表すのにも使用される | 範囲 -(27) to (27 - 1) (-128 to 127) | |
2 | TAG_Short | 2 bytes / 16 bits, signed, big endian | 符号付整数型 | 範囲 -(215) to (215 - 1) (-32,768 to 32,767) | |
3 | TAG_Int | 4 bytes / 32 bits, signed, big endian | 符号付整数型 | 範囲 -(231) to (231 - 1) (-2,147,483,648 to 2,147,483,647) | |
4 | TAG_Long | 8 bytes / 64 bits, signed, big endian | 符号付整数型. | 範囲 -(263) to (263 - 1) (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807) | |
5 | TAG_Float | 4 bytes / 32 bits, signed, big endian, IEEE 754-2008, binary32 | 符号付浮動小数点数. | Precision varies throughout number line; See Single-precision floating-point format. 最大値 3.4*1038 | |
6 | TAG_Double | 8 bytes / 64 bits, signed, big endian, IEEE 754-2008, binary64 | 符号付浮動小数点数 | Precision varies throughout number line; See Double-precision floating-point format. 最大値 1.8*10308 | |
7 | TAG_Byte_Array | TAG_Intで要素数 それから要素数分のTAG_Byteのペイロード. | バイト配列 | 最大要素数 (231 - 9) and (231 - 1) (2,147,483,639 and 2,147,483,647) JVMによる | |
8 | TAG_String | TAG_Shortのペイロードでバイト数 それからUTF-8文字列のバイト. | UTF-8でエンコードされた文字列。
サイズがあり、nullで終わることはない。 |
最大で32767バイト 詳しくはUTF-8フォーマットを参照 | |
9 | TAG_List | TAG_ByteのペイロードでTagタイプを決め、続いてTAG_Intのペイロードで要素数を決める。それから指定したタグIDのペイロードが続く。 | タグペイロードのリスト、なおTagIDは省略され名前も無い。 | 最大要素数は231-9個 または20億4748万3639個である。
(JVMの上限やjava.util.ArrayListの実装による) (リストは512回以上入れ子にできない) | |
10 | TAG_Compound | フリーフォーマットである。終端にTAG_Endを指定する。 | フリーフォーマット | JVMのメモリによるが、リストと違い、要素(タグ)の数に上限はない。(512回以上入れ子にはできない) | |
11 | TAG_Int_Array | TAG_Intのペイロードで要素数、それからTAG_Intのペイロードが要素数分続く。 | 4バイト整数配列 | Maximum number of elements ranges between (231 - 9) and (231 - 1) (2,147,483,639 and 2,147,483,647), depending on the specific JVM. |
The List and Compound tags can be and often are recursively nested. It should also be noted that, in a list of lists, each of the sub-lists can list a different kind of tag. 注意:要素数や文字数を示す型は符号付きである。
File Format
An NBT file is a GZip'd Compound tag, name and tag ID included. Some of the files utilized by Minecraft may be uncompressed, but in most cases the files follow Notch's original specification and are compressed with GZip. In the Xbox 360 Edition, chunks are compressed with XMemCompress, a variation of an LZX compression algorithm. There is no header to specify the version or any other information - only the level.dat file specifies the version.
As used in Minecraft
Minecraft's use of the NBT format is odd at times. In some instances, empty lists may be represented as a list of Byte tags rather than a list of the correct type, or as a list of End tags in newer versions of Minecraft, which can break some older NBT tools. Additionally, almost every root tag has an empty name string and encapsulates only one Compound tag with the actual data and a name. For instance:
- The root tag for most Minecraft NBT structures.
- SomeName: The only tag contained within the root tag - it has a name and contains all the actual data.
Another noticeable oddity is that, although the original specification by Notch allows for spaces in tag names, and even the example uses spaces in the tag names, Minecraft has no known files where any tags have spaces in their names. There is also inconsistent use of letter case, mostly either lowerCamelCase or UpperCamelCase, but sometimes even in all lowercase.
Uses
- level.dat is stored in compressed NBT format.
- <player>.dat files are stored in compressed NBT format.
- idcounts.dat is stored in uncompressed NBT format.
- villages.dat is stored in compressed NBT format.
- map_<#>.dat files are stored in compressed NBT format.
- servers.dat, which is used to store the list of saved multiplayer servers as uncompressed NBT.
- Chunks are stored in compressed NBT format within Region files.
- scoreboard.dat is stored in compressed NBT format.
- Generated structures are stored in compressed NBT format.
Software
Mojang has provided sample Java NBT classes for developers to use and reference as part of the source code for the McRegion -> Anvil converter. Other than this, the community has developed programs to view and modify compressed and uncompressed NBT files:
Name | NBT Version | Description | Screenshot |
---|---|---|---|
MineBack Ultimate | 19133 | MineBack Ultimate provides a full NBT editor supporting all available types of NBT format file (Map, Level, World etc.). It comes with a modern GUI and many helper functions. | |
NBTEdit | 19132 | Allows for viewing and modifying NBT files via a Windows tree control. It is outdated not only from being an NBT version behind, but because it does not support multiple tags with the same name and it forces incorrect ranges on some types, and it lacks support for uncompressed NBT files. | |
NBTExplorer - Forum Post | 19133 | Inspired by and based on NBTEdit, this program allows viewing and editing of NBT files via a Windows tree control. It supports compressed and uncompressed NBT files, and allows for direct editing of the NBT structures in MCRegion and Anvil files, level.dat, etc. | |
NBT grammar for Synalyze It! | 19132 | Using this grammar Synalyze It! displays a color-coded hex dump along with the parsed tag tree. Currently only uncompressed files are supported. | |
NEINedit | 19132 | NBT editor for mac with a text-based tree structure. | |
NBT2YAML | 19133 | nbt2yaml presents a command line interface for reading and editing Minecraft NBT files using a custom YAML format. It also includes a Python API for parsing and writing NBT files to/from a simple Python data structure. | |
webNBT | 19133 | webNBT is an NBT-editor that runs in modern browsers without requiring the user to download an application or use third-party browser plugins (like Flash or Java). |
ヘルプ | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
メニュー画面 |
| ||||||||||||||||
開発元 | |||||||||||||||||
ゲームのカスタマイズ | |||||||||||||||||
エディション |
| ||||||||||||||||
ゲーム |
| ||||||||||||||||
映画 |
| ||||||||||||||||
書籍 |
| ||||||||||||||||
その他メディア |
| ||||||||||||||||
イベント |
| ||||||||||||||||
公式商品 |
| ||||||||||||||||
その他 |