Skip to content

Parse and show Minecrafts NBT files in the command-line.

License

Notifications You must be signed in to change notification settings

Kesuaheli/nbtreader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3f0fc85 · Mar 20, 2025

History

37 Commits
Jul 14, 2024
Jul 12, 2024
Mar 25, 2023
Mar 16, 2024
Mar 25, 2023
Mar 20, 2025
Jul 14, 2024
Jul 14, 2024
Jun 24, 2024
Jul 14, 2024
Jun 24, 2024
Jul 8, 2024
Aug 3, 2024
Jul 13, 2024

Repository files navigation

nbtreader

Parse and show Minecrafts NBT files in the command-line.

Installing

Clone repo and build cli with Go

go build -o nbtreader ./cli

PS: For Windows its recommended to add a .exe to the filename:

go build -o nbtreader.exe ./cli

This produces an ready-to-use executable file named nbtreader (or nbtreader.exe). See next Section for using the command and its syntax.

You may want to add a symlink in your PATH to this file, so you can use this executable systemwide. In the following examples I call the command nbtreader to call the file.

Usage

After installation the binary can be used simply by passing a filename as argument:

nbtreader files/test.dat

produces

{
  name: "Bananrama"
}

and

nbtreader files/bigtest.nbt

produces

{
  longTest: 9223372036854775807l,
  shortTest: 32767s,
  stringTest: "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!",
  floatTest: 0.49823147f,
  intTest: 2147483647,
  nested compound test: {
    ham: {
      name: "Hampus",
      value: 0.75f
    },
    egg: {
      name: "Eggbert",
      value: 0.5f
    }
  },
  listTest (long): [11l, 12l, 13l, 14l, 15l],
  listTest (compound): [{
    name: "Compound tag #0",
    created-on: 1264099775885l
  }, {
    name: "Compound tag #1",
    created-on: 1264099775885l
  }],
  byteTest: 127b,
  byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...)): [B; 0b, 62b, <trimmed 996 values>, 6b, 48b],
  doubleTest: 0.4931287132182315d
}

If no file is given, nbtreader reads from stdin:

# e.g. with pipe
cat files/test.nbt | nbtreader
# or redirect
nbreader < files/test.nbt

Flags

Available flags are

  • -inType <string>
  • -outType <string>
  • uncompressed
  • -out <string>

Flag inType and outType

With theese flags you can specify the in- and output type.

Current valid values for inType:

  • NBT (default if ommited)

Current valid values for outType:

  • JSON
  • NBT
  • NJSON (see spec)
  • SNBT (default if ommited)

Example:

nbtreader -outType JSON files/test.nbt

produces

{
	"name": "Bananrama"
}

Flag uncompressed

When using the -outType NBT option the output file will be written in compressed format using GZip. However, you can pass in the -uncompressed flag to write the NBT data in raw without compressing them.

nbtreader -outType NBT -uncompressed -out files/output_raw.nbt files/test.nbt

Using -uncompressed without setting the outType to NBT has no effect and is silently igonred.

Flag out

To easily save the result in a file you could once again use redirecting:

nbtreader files/test.nbt > files output.txt

However, if you pass in the optional flag -out <filename> the output is instead written to the given filename:

nbtreader -out files/output.txt files/test.nbt

About

Parse and show Minecrafts NBT files in the command-line.

Resources

License

Stars

Watchers

Forks

Packages

No packages published