diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java | 12 | ||||
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java | 4 | ||||
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java (renamed from src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/AlwaysFailCondition.java) | 10 | ||||
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java | 5 |
4 files changed, 18 insertions, 13 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java index 7cc5724..3bc708f 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java @@ -18,10 +18,14 @@ public class CIT<T extends CITType> { } public boolean test(CITContext context) { - for (CITCondition condition : conditions) - if (!condition.test(context)) - return false; + try { + for (CITCondition condition : conditions) + if (!condition.test(context)) + return false; - return true; + return true; + } catch (Exception ignored) { + return false; + } } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java index 326ec76..ff38ef8 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java @@ -4,7 +4,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.util.Identifier; import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer; import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer; -import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.AlwaysFailCondition; +import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.ConstantCondition; import shcm.shsupercm.fabric.citresewn.ex.CITParsingException; import shcm.shsupercm.fabric.citresewn.ex.UnknownCITTypeException; import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup; @@ -45,7 +45,7 @@ public class CITRegistry { CITConditionContainer<? extends CITCondition> conditionContainer = CONDITIONS.get(key); if (conditionContainer == null) { logWarnLoading(CITParsingException.descriptionOf("Unknown condition type \"" + key.toString() + "\"", properties, value.position())); - return new AlwaysFailCondition(); + return new ConstantCondition(false); } CITCondition condition = conditionContainer.createCondition.get(); diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/AlwaysFailCondition.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java index 5c32d97..081c2d8 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/AlwaysFailCondition.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java @@ -6,7 +6,13 @@ import shcm.shsupercm.fabric.citresewn.ex.CITParsingException; import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup; import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue; -public class AlwaysFailCondition extends CITCondition { +public class ConstantCondition extends CITCondition { + public final boolean value; + + public ConstantCondition(boolean value) { + this.value = value; + } + @Override public void load(PropertyValue value, PropertyGroup properties) throws CITParsingException { @@ -14,6 +20,6 @@ public class AlwaysFailCondition extends CITCondition { @Override public boolean test(CITContext context) { - return false; + return value; } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java index 6ad3783..2e887d6 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java @@ -24,9 +24,4 @@ public class WeightCondition extends IntegerCondition { public void setWeight(int weight) { this.min = weight; } - - @Override - protected int getValue(CITContext context) { - return 0; - } } |