Integrated Dynamics - On the Dynamics of Integration

NBT Path

When working with complex NBT tags, you can quickly require complex operator chains for reading deeply nested NBT values. In order to to simplify this task, String-based NBT Path expressions can be used to determine the path within an NBT tag.

The simplest NBT Path expression is made up of a chain of field selectors, such as .fieldName or .[”fieldName”].

For example, applying the expression ”.root.child1.child2” on the NBT tag { root: { child1: { child2: ”some value” } }} will output ”some value”.

Multiple fields can be selected by providing an array of field names or a wildcard, for example [fieldA,fieldB] or *

For example, applying the expression ”.a[b1,b2]*” on the NBT tag { a: { b1: { c: ”some value” } }} will output ”some value”.

When working with NBT lists, specific entries can be selected by specifying an index, such as [1].

For example, applying the expression ”.a[1]” on the NBT tag { a: [10,20] } will output ”20”.

Multiple list indexes can be selected using the slice operator: [start:end:step]. (Only start is required, the other elements may be omitted)

For example, applying the expression ”.a[1:4:2]” on the NBT tag { a: [0,1,2,3,4,5] } will output [1,3].

More advanced filter expressions are also possible using the filter syntax, for example [?(@.childName < 10)] (@ refers to the current tag, .. refers to the parent tag, $ refers to the root tag)

For example, applying the expression ”$.a[?(@ == 3)]” on the NBT tag { a: [0,1,2,3,4,5] } will output [3].

Operator
NBT Path Match FirstNBT.path_match_firstApply the given NBT Path expression on the given NBT value, and return the first match
  • String
  • NBT
  • NBT
Global name: stringNbtPathMatchFirst(StringNBT) → NBTMethod name: String.nbtPathMatchFirst(NBT) → NBT
Operator
NBT Path Match AllNBT.path_match_allApply the given NBT Path expression on the given NBT value, and return all matches as a list
  • String
  • NBT
  • List
Global name: stringNbtPathMatchAll(StringNBT) → ListMethod name: String.nbtPathMatchAll(NBT) → List
Operator
NBT Path TestNBT.path_testTest if the given NBT Path expression matches with the given NBT value
  • String
  • NBT
  • Boolean
Global name: stringNbtPathTest(StringNBT) → BooleanMethod name: String.nbtPathTest(NBT) → Boolean