From ba570a6b2e37f6f45b149515cd41d10037cbda7f Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Sun, 6 Feb 2022 15:00:29 +0200 Subject: Built more runtime api --- .../fabric/citresewn/pack/cit/CITCondition.java | 15 +++++++++++ .../fabric/citresewn/pack/cit/CITContext.java | 30 +++++++++++++++++++++- .../fabric/citresewn/pack/cit/CITType.java | 5 ++++ 3 files changed, 49 insertions(+), 1 deletion(-) (limited to 'src/main/java/shcm') 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> acceptedTypes() { + return null; + } + + public Set> siblingConditions() { + return Collections.emptySet(); + } + + public 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 modifyConditions(List conditions) { + return conditions; + } } -- cgit