diff options
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(); + } +} |