Package: nbt2yaml
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.The key tool isnbtedit, a command line utility that will shell out the
YAML version of the target NBT file to your editor of choice, allowing
relatively easy editing of NBT data. When the editing session is closed, the
saved file is parsed back into NBT, and if changes have occurred, the original
file is updated; a copy of the previous version is saved as well.NBT format:http://wiki.vg/NBTYAML:http://www.yaml.org/InstallationFirst,be sure to readthedisclaimerdown below.Install viapip:pip install nbt2yamlOnce installed, thenbtedit,nbt2yaml, andyaml2nbtcommands should
be available, from the same place other Python utilities are installed.CommandsNote that an nbt file is typically in gzip format. nbt2yaml commands will
assume gzip format for all nbt files written and read, unless the--no-gzipflag is specified.For thenbt2yamlandyaml2nbtcommands, the filename can be specified
as-, which indicates the data should be read from standard input.nbteditEdits an nbt file in-place, allowing YAML format within the editor.The script uses the standardEDITORenvironment variable to determine which
text editor should be invoked.The program detects if changes were made when the editing session is closed;
if so, the existing nbt file is copied to a backup unconditionally, and the new
data is written to the file in place.Synopsis:usage: nbtedit [-h] [-n] filename

Edit an nbt file in-place in Yaml format.

positional arguments:
  filename       filename

optional arguments:
  -h, --help     show this help message and exit
  -n, --no-gzip  Don't use gzipnbt2yamlDumps an nbt file as YAML to standard output:usage: nbt2yaml [-h] [-n] filename

Dump an nbt file or stream to yaml.

positional arguments:
  filename       Filename. Specify as '-' to read from stdin.

optional arguments:
  -h, --help     show this help message and exit
  -n, --no-gzip  Don't use gzipyaml2nbtDumps a YAML file generated by nbt2yaml as nbt to standard output:usage: yaml2nbt [-h] [-n] filename

Dump a yaml file or stream to nbt.

positional arguments:
  filename       Filename. Specify as '-' to read from stdin.

optional arguments:
  -h, --help     show this help message and exit
  -n, --no-gzip  Don't use gzipExample UseSuppose we want to switch the “GameMode” from “0” (survival) to “1”
(creative).First, ensure that Minecraft itself isnot running.  Then, navigate to
where your Minecraft save files are.  Here’s how it looks on a mac:$ cd ~/Library/Application\ Support/minecraft/saves/Once there, edit thelevel.datfile for any selected world:nbtedit myworld/level.datAssuming you have your EDITOR variable set, an editor likevim,nano,emacs,
or something else should pop up.   Window based editors can be used
if they present a command line command that doesn’t exit until the file is saved
(such as, I can usemate-where to use TextMate).Then navigate down to the “GameType” value:- foodSaturationLevel: 0.0
  - FallDistance: 0.0
  - XpTotal: 0
  - Rotation:
    - -476.3782043457031
    - 28.349964141845703
  - Xp: 0
- RandomSeed: !long "1201953322384967445"
- GameType: 0
- MapFeatures: !byte "0"
- version: 19132
- Time: !long "5601373"
- raining: !byte "0"
- thunderTime: 19527Change it from “0” (survival) to “1” (creative):- RandomSeed: !long "1201953322384967445"
- GameType: 1
- MapFeatures: !byte "0"Save the file.nbteditreports that it saved a copy of the old file and wrote
the changes to the existing file.   Now you can build some castles !FormatThe specifics of how NBT is mapped to YAML is of course a
decision this program has to make, as there are any
number of ways to do it. The goal here is to have a YAML
format that is as minimal and readable as possible, while
still maintaining the ability to write the identical nbt
file as the one parsed; for this reason, many datatypes
have explicit directives (i.e. short, long, double, byte)
which will result in the appropriate nbt tag (i.e.
TAG_Short, TAG_Long, TAG_Double, TAG_Byte). The default
forint,strandfloatPython types are
TAG_Int, TAG_String, and TAG_Float, respectively.When editing a YAML file, it’s important to keep the
formattingexactlythe same! nbt2yaml can only handle
structures that are in the form in which it generates;
see the example below to see all of these forms.While nbt2yaml can handle any kind of data provided the
format is correct, it’s expected that the normal use of
this tool is just to change individual values without
changing the document structure.A current dump of the Minecraft reference filebigtest.nbtin YAML format is below. Suggestions on
improving this format are welcome !Level:
- longTest: !long "9223372036854775807"
- shortTest: !short "32767"
- stringTest: !!python/str "HELLO WORLD THIS IS A TEST STRING \xC5\xC4\xD6!"
- floatTest: 0.4982314705848694
- intTest: 2147483647
- nested compound test:
  - ham:
    - name: Hampus
    - value: 0.75
  - egg:
    - name: Eggbert
    - value: 0.5
- listTest (long):
  - !long "11"
  - !long "12"
  - !long "13"
  - !long "14"
  - !long "15"
- listTest (compound):
  - - name: 'Compound tag #0'
    - created-on: !long "1264099775885"
  - - name: 'Compound tag #1'
    - created-on: !long "1264099775885"
- byteTest: !byte "127"
- byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...)): !byte_array "00\
    \ 3E 22 10 08 0A 16 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E\
    \ 54 10 3A 0A 48 2C 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54\
    \ 42 3A 3C 48 5E 1A 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42\
    \ 08 3C 16 5E 4C 44 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08\
    \ 0A 16 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A\
    \ 48 2C 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48\
    \ 5E 1A 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E\
    \ 4C 44 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08 0A 16 2C 4C\
    \ 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A 48 2C 1A 12\
    \ 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48 5E 1A 44 14\
    \ 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E 4C 44 46 52\
    \ 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08 0A 16 2C 4C 12 46 20 04\
    \ 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A 48 2C 1A 12 14 20 36 56\
    \ 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48 5E 1A 44 14 52 36 24 1C\
    \ 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E 4C 44 46 52 04 24 4E 1E\
    \ 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08 0A 16 2C 4C 12 46 20 04 56 4E 50 5C\
    \ 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A 48 2C 1A 12 14 20 36 56 1C 50 2A 0E\
    \ 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48 5E 1A 44 14 52 36 24 1C 1E 2A 40 60\
    \ 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E 4C 44 46 52 04 24 4E 1E 5C 40 2E 26\
    \ 28 34 4A 06 30 00 3E 22 10 08 0A 16 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28\
    \ 02 4A 38 30 32 3E 54 10 3A 0A 48 2C 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02\
    \ 18 38 62 32 0C 54 42 3A 3C 48 5E 1A 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18\
    \ 06 62 00 0C 22 42 08 3C 16 5E 4C 44 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06\
    \ 30 00 3E 22 10 08 0A 16 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30\
    \ 32 3E 54 10 3A 0A 48 2C 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32\
    \ 0C 54 42 3A 3C 48 5E 1A 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C\
    \ 22 42 08 3C 16 5E 4C 44 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22\
    \ 10 08 0A 16 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10\
    \ 3A 0A 48 2C 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A\
    \ 3C 48 5E 1A 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C\
    \ 16 5E 4C 44 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08 0A 16\
    \ 2C 4C 12 46 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A 48 2C\
    \ 1A 12 14 20 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48 5E 1A\
    \ 44 14 52 36 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E 4C 44\
    \ 46 52 04 24 4E 1E 5C 40 2E 26 28 34 4A 06 30 00 3E 22 10 08 0A 16 2C 4C 12 46\
    \ 20 04 56 4E 50 5C 0E 2E 58 28 02 4A 38 30 32 3E 54 10 3A 0A 48 2C 1A 12 14 20\
    \ 36 56 1C 50 2A 0E 60 58 5A 02 18 38 62 32 0C 54 42 3A 3C 48 5E 1A 44 14 52 36\
    \ 24 1C 1E 2A 40 60 26 5A 34 18 06 62 00 0C 22 42 08 3C 16 5E 4C 44 46 52 04 24\
    \ 4E 1E 5C 40 2E 26 28 34 4A 06 30"
- doubleTest: !double "0.4931287132182315"Disclaimernbtedit isvery old now, but the last time I did anything with it, it was brand new.
Back when it was September, 2011, you would have been one of thefirstpeople reading this README. But I am now writing this in February of 2021, so
you are likely the.. one..two….seventh, yes, likely the seventh, maybe eighth?person to read this,
but nonetheless, this is not a widely used tool
so you may very well be the person to find some new bugs! It’s also very
possible that an incorrectly edited YAML file could save an NBT file that
Minecraft no longer knows how to read.Back EVERYTHING up before tinkering with your files !!nbtedit saves a
backup of each file it edits, butdon’t rely solely on that!Please note
you areusing this editor at your own risk. The code is unit tested, works
great, but I’d hate to be the reason you screwed up your world somake copies
of all files being edited first. Thanks!