aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-03-25 11:51:59 +0300
committerSHsuperCM <shsupercm@gmail.com>2022-03-25 11:51:59 +0300
commit0484498863626dc57d55d381b7b394b5cc9234c2 (patch)
treec2329a89ac1ebdae17822b88a8c2ab5429d4086f /src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin
parent162f9b7cf8ae24c950673a32e695e59e4e807f39 (diff)
downloadCITResewn-0484498863626dc57d55d381b7b394b5cc9234c2.tar.gz
CITResewn-0484498863626dc57d55d381b7b394b5cc9234c2.tar.bz2
CITResewn-0484498863626dc57d55d381b7b394b5cc9234c2.zip
Cleanup with built in conditions
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java40
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/core/WeightCondition.java (renamed from src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/WeightCondition.java)8
2 files changed, 32 insertions, 16 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java
index 5bc9354..ed967c1 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/builtin/conditions/ConstantCondition.java
@@ -9,23 +9,43 @@ import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
/**
* Common condition type with no parsing for constant true/false testing output.
*/
-public class ConstantCondition extends CITCondition {
+public abstract class ConstantCondition extends CITCondition {
/**
- * What testing contexts will always result in.
+ * Constant condition that always tests positive.
*/
- public final boolean value;
+ public static final ConstantCondition TRUE = new ConstantCondition(true) {
+ @Override
+ public boolean test(CITContext context) {
+ return true;
+ }
+ };
- public ConstantCondition(boolean value) {
- this.value = value;
+ /**
+ * Constant condition that always tests negative.
+ */
+ public static final ConstantCondition FALSE = new ConstantCondition(false) {
+ @Override
+ public boolean test(CITContext context) {
+ return false;
+ }
+ };
+
+ /**
+ * @return constant condition for the given boolean value
+ */
+ public static ConstantCondition of(boolean value) {
+ return value ? TRUE : FALSE;
}
- @Override
- public void load(PropertyValue value, PropertyGroup properties) throws CITParsingException {
+ /**
+ * What testing contexts will always result in.
+ */
+ public final boolean value;
+ private ConstantCondition(boolean value) {
+ this.value = value;
}
@Override
- public boolean test(CITContext context) {
- return value;
- }
+ public void load(PropertyValue value, PropertyGroup properties) throws CITParsingException { }
}
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/core/WeightCondition.java
index a53e019..cb728c9 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/core/WeightCondition.java
@@ -1,12 +1,8 @@
-package shcm.shsupercm.fabric.citresewn.cit.builtin.conditions;
+package shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.core;
import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint;
import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer;
-import shcm.shsupercm.fabric.citresewn.ex.CITParsingException;
-import shcm.shsupercm.fabric.citresewn.cit.CITCondition;
-import shcm.shsupercm.fabric.citresewn.cit.CITContext;
-import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup;
-import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
+import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.IntegerCondition;
/**
* Internal condition used to determine the priority CITs get tested in.<br>