diff options
author | SHsuperCM <shsupercm@gmail.com> | 2022-09-10 10:58:58 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2022-09-10 10:58:58 +0300 |
commit | f82becce3a0def5652d93d35759ce333352ec6b8 (patch) | |
tree | 64b5b67fcf7bd8138ddad2a2fdad663cf0ea9b84 | |
parent | 736f838416a4f96c6e0c23a6658381835096993d (diff) | |
download | CITResewn-f82becce3a0def5652d93d35759ce333352ec6b8.tar.gz CITResewn-f82becce3a0def5652d93d35759ce333352ec6b8.tar.bz2 CITResewn-f82becce3a0def5652d93d35759ce333352ec6b8.zip |
Added count check to nbt list conditions
Closes #195
-rw-r--r-- | defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java index 3157866..e382d6f 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java @@ -108,10 +108,14 @@ public class ConditionNBT extends CITCondition { } else { if (element instanceof NbtCompound compound) return testPath(compound.get(path), pathIndex + 1); - else if (element instanceof NbtList list) + else if (element instanceof NbtList list) { + if (path.equals("count")) + return testValue(NbtInt.of(list.size())); + try { return testPath(list.get(Integer.parseInt(path)), pathIndex + 1); } catch (NumberFormatException | IndexOutOfBoundsException ignored) { } + } } return false; |