From f82becce3a0def5652d93d35759ce333352ec6b8 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Sat, 10 Sep 2022 10:58:58 +0300 Subject: Added count check to nbt list conditions Closes #195 --- .../fabric/citresewn/defaults/cit/conditions/ConditionNBT.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'defaults/src/main/java/shcm/shsupercm') 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; -- cgit