aboutsummaryrefslogtreecommitdiff
path: root/defaults/src/main/java/shcm
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-17 12:55:24 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-17 12:55:24 +0200
commit1ec38a503f3b88c9de1e29319548b5a6e6098707 (patch)
treed61033e56ef8e3fb908d4451fe55d918b63f4f3c /defaults/src/main/java/shcm
parent4615af9f467be065426d217375c3b3bd4203afe7 (diff)
downloadCITResewn-1ec38a503f3b88c9de1e29319548b5a6e6098707.tar.gz
CITResewn-1ec38a503f3b88c9de1e29319548b5a6e6098707.tar.bz2
CITResewn-1ec38a503f3b88c9de1e29319548b5a6e6098707.zip
Implemented conditions stackSize, damage, damageMask
Diffstat (limited to 'defaults/src/main/java/shcm')
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamage.java46
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamageMask.java30
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionStackSize.java21
3 files changed, 97 insertions, 0 deletions
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamage.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamage.java
new file mode 100644
index 0000000..c5c31f9
--- /dev/null
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamage.java
@@ -0,0 +1,46 @@
+package shcm.shsupercm.fabric.citresewn.defaults.cit.conditions;
+
+import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint;
+import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer;
+import shcm.shsupercm.fabric.citresewn.cit.CITCondition;
+import shcm.shsupercm.fabric.citresewn.cit.CITContext;
+import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.IntegerCondition;
+
+import java.util.Set;
+
+public class ConditionDamage extends IntegerCondition {
+ @Entrypoint(CITConditionContainer.ENTRYPOINT)
+ public static final CITConditionContainer<ConditionDamage> CONTAINER = new CITConditionContainer<>(ConditionDamage.class, ConditionDamage::new,
+ "damage");
+
+ protected Integer mask = null;
+
+ public ConditionDamage() {
+ super(true, false, true);
+ }
+
+ @Override
+ protected int getValue(CITContext context) {
+ int value = context.stack.isDamageable() ? context.stack.getDamage() : 0;
+ if (mask != null)
+ value &= mask;
+ return value;
+ }
+
+ @Override
+ protected int getPercentageTotalValue(CITContext context) {
+ return context.stack.isDamageable() ? context.stack.getItem().getMaxDamage() : 0;
+ }
+
+ @Override
+ public Set<Class<? extends CITCondition>> siblingConditions() {
+ return Set.of(ConditionDamageMask.class);
+ }
+
+ @Override
+ public <T extends CITCondition> T modifySibling(T sibling) {
+ if (sibling instanceof ConditionDamageMask damageMask)
+ this.mask = damageMask.getMask();
+ return null;
+ }
+}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamageMask.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamageMask.java
new file mode 100644
index 0000000..6c8e9e0
--- /dev/null
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionDamageMask.java
@@ -0,0 +1,30 @@
+package shcm.shsupercm.fabric.citresewn.defaults.cit.conditions;
+
+import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint;
+import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer;
+import shcm.shsupercm.fabric.citresewn.cit.CITContext;
+import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.IntegerCondition;
+
+public class ConditionDamageMask extends IntegerCondition {
+ @Entrypoint(CITConditionContainer.ENTRYPOINT)
+ public static final CITConditionContainer<ConditionDamageMask> CONTAINER = new CITConditionContainer<>(ConditionDamageMask.class, ConditionDamageMask::new,
+ "damageMask");
+
+ public ConditionDamageMask() {
+ super(false, false, false);
+ }
+
+ @Override
+ protected int getValue(CITContext context) {
+ return 0;
+ }
+
+ @Override
+ public boolean test(CITContext context) {
+ return true;
+ }
+
+ public int getMask() {
+ return this.min;
+ }
+}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionStackSize.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionStackSize.java
new file mode 100644
index 0000000..1d22a53
--- /dev/null
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionStackSize.java
@@ -0,0 +1,21 @@
+package shcm.shsupercm.fabric.citresewn.defaults.cit.conditions;
+
+import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint;
+import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer;
+import shcm.shsupercm.fabric.citresewn.cit.CITContext;
+import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.IntegerCondition;
+
+public class ConditionStackSize extends IntegerCondition {
+ @Entrypoint(CITConditionContainer.ENTRYPOINT)
+ public static final CITConditionContainer<ConditionStackSize> CONTAINER = new CITConditionContainer<>(ConditionStackSize.class, ConditionStackSize::new,
+ "stack_size", "stackSize", "amount");
+
+ public ConditionStackSize() {
+ super(true, false, false);
+ }
+
+ @Override
+ protected int getValue(CITContext context) {
+ return context.stack.getCount();
+ }
+}