NBTパス


When working with complex NBT tags, you can quickly require complex operator chains for reading deeply nested NBT values. In order 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”].

たとえば、式".root.child1.child2”NBTタグ{ root: { child1: { child2: ”some value” }}}に適用すると、”some value”が出力されます。

フィールド名の配列またはワイルドカードを指定することで、複数のフィールドを選択できます。例: [fieldA,fieldB]または*

たとえば、式".a[b1,b2]*”NBTタグ{ a: { b1: { c: ”some value” }}}に適用すると、”some value”が出力されます。

NBTリストを操作する場合、[1]などのインデックスを指定して特定のエントリを選択できます。

たとえば、式".a[1]”NBTタグ{ a: [10,20] }に適用すると、”20”が出力されます。

スライス演算子を使用して、複数のリストインデックスを選択できます: [start:end:step] (開始のみが必須で、他の要素は省略できます)

たとえば、式".a[1:4:2]"NBTタグ{ a: [0,1,2,3,4,5] }に適用すると、[1,3]が出力されます。

フィルター構文を使用すると、より高度なフィルター式も使用できます。たとえば、[?(@.childName < 10)](@は現在のタグ、..は親タグ、$はルートタグを参照します)

たとえば、式”$.a[?(@ == 3)]”NBTタグ{ a: [0,1,2,3,4,5] }に適用すると、[3]が出力されます。

Expressions can be combined using ”§§” (and), ”||” (or), and ”!” (not).

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

演算子
NBT Path Match FirstNBT.path_match_firstApply the given NBT Path expression on the given NBT value, and return the first match
  • 文字列
  • NBT
  • NBT
グローバル名: stringNbtPathMatchFirst(文字列NBT) → NBTメソッド名: 文字列.nbtPathMatchFirst(NBT) → NBT
演算子
NBT Path Match AllNBT.path_match_allApply the given NBT Path expression on the given NBT value, and return all matches as a list
  • 文字列
  • NBT
  • リスト
グローバル名: stringNbtPathMatchAll(文字列NBT) → リストメソッド名: 文字列.nbtPathMatchAll(NBT) → リスト
演算子
NBT Path TestNBT.path_testTest if the given NBT Path expression matches with the given NBT value
  • 文字列
  • NBT
  • ブール
グローバル名: stringNbtPathTest(文字列NBT) → ブールメソッド名: 文字列.nbtPathTest(NBT) → ブール