aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-22 17:11:14 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-22 17:11:14 +0200
commit2d99c1b5773eb4067bb873e21c409a9a2399ab3d (patch)
tree3d4553c54f7a17a6ce08febe435c4e9f05612a16 /src/main/java/shcm/shsupercm
parentadf0277b743ed79a4bad6d3c6011f2cec3bea600 (diff)
downloadCITResewn-2d99c1b5773eb4067bb873e21c409a9a2399ab3d.tar.gz
CITResewn-2d99c1b5773eb4067bb873e21c409a9a2399ab3d.tar.bz2
CITResewn-2d99c1b5773eb4067bb873e21c409a9a2399ab3d.zip
Cleaned/fixed some stuff up
Diffstat (limited to 'src/main/java/shcm/shsupercm')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java12
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java4
-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.java5
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;
- }
}