Skip to content

NBT Tools | NBTQuery

WolfyScript edited this page Nov 17, 2022 · 9 revisions

The NBTQuery makes it possible to fetch specific data from NBT.

The way it works is that the NBTQuery constructs a NBTComound, of the values it was specified to fetch, and then returns it. That compound can be then used for anything, like merging it with other items NBT Tags (See CustomCraftings' NBTMergeAdapter).

The query is written in JSON and provides options to filter elements by value, index in lists, and child NBT nodes. To build the query and describe the desired output, you can use the following settings.

General Settings

Can be used for all types of NBT Tags (including primitive, compound, lists, etc.)

By using a boolean value, you can either not include a Tag in a result (false default), or include it (true).
When used for Compounds, it includes the whole Compound with all child tags!
For List Tags, it includes the whole list.

Example:

"<tag_key>": true

Primitive Settings

Includes the tag if it matches the specified value.

String

"<tag_key>": "<value>"

Byte

"<tag_key>": "<value>b",
// or
"<tag_key>": "<value>B"

Short

"<tag_key>": "<value>s",
// or
"<tag_key>": "<value>S"

Integer

"<tag_key>": "<value>i",
// or
"<tag_key>": "<value>I",
// or
"<tag_key>": <value>

Long

"<tag_key>": "<value>l",
// or
"<tag_key>": "<value>L"

Double

"<tag_key>": "<value>d",
// or
"<tag_key>": "<value>D",
// or
"<tag_key>": <value>

Float

"<tag_key>": "<value>f",
// or
"<tag_key>": "<value>F"

Compound Settings

type: compound

Includes the Compound Tag with all the children that match the inclusion settings.

Properties

  • preservePath (Default: true): Keeps the path of the parent and child tags.
  • includeAll (Default: false): Determines the default value of each includes child.
  • includes (Default: {}): Specifies the includes values of the children. Each child set to true will be included.
  • children (Default: {}): Proceeds to child tags. In case includes is not empty, then it only proceeds to included child tags!
"<tag_key>": {
  "type": "compound",
  "preservePath": true, // Optional: keeps the path of the parent and child tags.
  "includesAll": false, // Optional: determines the default value for each `includes` child.
  // Optional: Only includes and computes the specified children.
  "includes": {
    "<child_key>": true, // true or false
    // If a key is not specified it will use the value from `includesAll`
  },
  // Proceed to child tags. If `includes` is used, then it just proceeds to the included child tags!
  "children": {
    "<child_key>": /*<child_settings>*/
  },
  //Optional, child keys may be directly written into the root of the compound settings.
  "<child_key>": /*<child_settings>*/
}

List Settings

type: list/<string|byte|short|long|int|double|float>

Includes the NBT List Tag with the specified values.

Properties

  • elements (Default: []): List of settings for tags to be included.
    • List entry:
      • index (Optional): Returns the value at the specified index, if it matches the setting.
      • value (Optional, Default: true): The value settings (primitive, compound, etc. depending on list type)
"<tag_key>": {
  "type": "list/<string|byte|short|long|int|double|float|compound>",
  "elements": [
    {
      "index": 0, //Optional: Returns the value at the specified index, if it matches the setting.
      "value": /*value settings*/ //Optional: The value settings (primitive, compound, etc. depending on list type)
    },
    //...
  ]
}

| Home

| GUIs

| NBT Tools

Clone this wiki locally