Emacs major mode for editing Minecraft NBT files
Files
README.md
# nbt-mode An Emacs major mode for editing Minecraft Named Binary Tag (NBT) files. NBT is binary, so files are decoded into SNBT -- the stringified format used by Java Edition commands -- presented as ordinary text, and re-serialized back to binary when you save. The compression the file was read with (gzip, zlib or none) is remembered and reused. ## Installation Clone the repository and load it from your init file: ```elisp (add-to-list 'load-path "/path/to/nbt-mode.el") (require 'nbt-mode) ``` Visiting a file ending in `.dat`, `.nbt`, `.schem`, `.mcstructure` or `.dat_old` decodes it automatically; adjust `nbt-auto-detect-regex` to taste. Any other file can be opened with `M-x nbt-find-file`. ## Usage Edit the buffer like plain text and save with `C-x C-s`. Parse errors report their position and jump there instead of writing a broken file. | Key | Command | What it does | |---------|-----------------------|-----------------------------------| | `C-c C-c` | `save-buffer` | Serialize edits back to binary | | `C-c C-r` | `nbt-reformat` | Rewrite buffer in canonical form | | `C-c C-z` | `nbt-set-compression` | Choose gzip / zlib / none | The root tag's name (usually empty, since SNBT cannot express it) is kept in `nbt-root-name`; a leading `name:` before the opening brace sets it. ## Requirements Emacs 28 or newer. Saving compressed files needs the `gzip` program; decompression uses Emacs' built-in zlib when available. ## Region files Anvil region files (`.mca`) are supported. Each chunk appears as an entry named `"x,z"` in the root compound; chunk timestamps and compression are preserved when you save, and LZ4 (Minecraft 1.20.5+) or external `.mcc` chunks are reported as errors rather than dropped. ## Tests ```sh emacs --batch -Q -L . -L test -l test/nbt-mode-tests.el \ -f ert-run-tests-batch-and-exit ``` They also run on every push via Spindles (see `.tangled/workflows/test.yml`).