diff options
author | SHsuperCM <shsupercm@gmail.com> | 2022-02-06 15:00:29 +0200 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2022-02-06 15:00:29 +0200 |
commit | ba570a6b2e37f6f45b149515cd41d10037cbda7f (patch) | |
tree | db066365b90735892c8ed7c6263dbb330f87071a /src/main/java/shcm | |
parent | 31a31ef5a357bbf180ef9e438771cc8623317194 (diff) | |
download | CITResewn-ba570a6b2e37f6f45b149515cd41d10037cbda7f.tar.gz CITResewn-ba570a6b2e37f6f45b149515cd41d10037cbda7f.tar.bz2 CITResewn-ba570a6b2e37f6f45b149515cd41d10037cbda7f.zip |
Built more runtime api
Diffstat (limited to 'src/main/java/shcm')
3 files changed, 49 insertions, 1 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java index 736afac..e117133 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java @@ -2,8 +2,23 @@ package shcm.shsupercm.fabric.citresewn.pack.cit; import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue; +import java.util.Collections; +import java.util.Set; + public abstract class CITCondition { public abstract void load(String keyMetadata, PropertyValue value) throws Exception; + public Set<Class<? extends CITType>> acceptedTypes() { + return null; + } + + public Set<Class<? extends CITCondition>> siblingConditions() { + return Collections.emptySet(); + } + + public <T extends CITCondition> T modifySibling(T sibling) { + return sibling; + } + public abstract boolean test(CITContext context); } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java index a4e0d11..d8d66ad 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java @@ -1,4 +1,32 @@ package shcm.shsupercm.fabric.citresewn.pack.cit; -public record CITContext() { +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import java.util.Objects; + +public class CITContext { + public final ItemStack stack; + public final World world; + public final LivingEntity entity; + + public CITContext(ItemStack stack, World world, LivingEntity entity) { + this.stack = stack; + this.world = world; + this.entity = entity; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof CITContext that && + Objects.equals(this.stack, that.stack) && + Objects.equals(this.world, that.world) && + Objects.equals(this.entity, that.entity); + } + + @Override + public int hashCode() { + return Objects.hash(stack, world, entity); + } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java index c10e29f..557a34c 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java @@ -1,4 +1,9 @@ package shcm.shsupercm.fabric.citresewn.pack.cit; +import java.util.List; + public abstract class CITType { + public List<? extends CITCondition> modifyConditions(List<? extends CITCondition> conditions) { + return conditions; + } } |