From 31a31ef5a357bbf180ef9e438771cc8623317194 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Sun, 6 Feb 2022 05:36:23 +0200 Subject: Started runtime CIT structure --- .../fabric/citresewn/mixin/ModelLoaderMixin.java | 2 +- .../fabric/citresewn/pack/ActiveCITs.java | 45 --------------------- .../fabric/citresewn/pack/cit/ActiveCITs.java | 47 ++++++++++++++++++++++ .../shsupercm/fabric/citresewn/pack/cit/CIT.java | 17 ++++++++ .../fabric/citresewn/pack/cit/CITCondition.java | 9 +++++ .../fabric/citresewn/pack/cit/CITContext.java | 4 ++ .../fabric/citresewn/pack/cit/CITType.java | 4 ++ 7 files changed, 82 insertions(+), 46 deletions(-) delete mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/ActiveCITs.java create mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java create mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CIT.java create mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java create mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java create mode 100644 src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java (limited to 'src') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java index f8b2979..e5e000d 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import shcm.shsupercm.fabric.citresewn.pack.ActiveCITs; +import shcm.shsupercm.fabric.citresewn.pack.cit.ActiveCITs; @Mixin(ModelLoader.class) public class ModelLoaderMixin { diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/ActiveCITs.java deleted file mode 100644 index 642b950..0000000 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/ActiveCITs.java +++ /dev/null @@ -1,45 +0,0 @@ -package shcm.shsupercm.fabric.citresewn.pack; - -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.profiler.Profiler; -import shcm.shsupercm.fabric.citresewn.api.Disposable; - -public class ActiveCITs implements Disposable { private ActiveCITs() {} - private static ActiveCITs active = null; - - public static ActiveCITs getActive() { - return active; - } - - public static boolean isActive() { - return active != null; - } - - public final GlobalProperties globalProperties = new GlobalProperties(); - - public static ActiveCITs load(ResourceManager resourceManager, Profiler profiler) { - profiler.push("citresewn:disposing"); - if (active != null) { - active.dispose(); - active = null; - } - - ActiveCITs active = new ActiveCITs(); - - profiler.swap("citresewn:load_global_properties"); - PackParser.loadGlobalProperties(resourceManager, active.globalProperties); - active.globalProperties.callHandlers(); - profiler.pop(); - - return ActiveCITs.active = active; - } - - @Override - public void dispose() { - for (Disposable disposable : FabricLoader.getInstance().getEntrypoints(Disposable.ENTRYPOINT, Disposable.class)) - disposable.dispose(); - - - } -} diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java new file mode 100644 index 0000000..f8df1ee --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java @@ -0,0 +1,47 @@ +package shcm.shsupercm.fabric.citresewn.pack.cit; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.resource.ResourceManager; +import net.minecraft.util.profiler.Profiler; +import shcm.shsupercm.fabric.citresewn.api.Disposable; +import shcm.shsupercm.fabric.citresewn.pack.GlobalProperties; +import shcm.shsupercm.fabric.citresewn.pack.PackParser; + +public class ActiveCITs implements Disposable { private ActiveCITs() {} + private static ActiveCITs active = null; + + public static ActiveCITs getActive() { + return active; + } + + public static boolean isActive() { + return active != null; + } + + public final GlobalProperties globalProperties = new GlobalProperties(); + + public static ActiveCITs load(ResourceManager resourceManager, Profiler profiler) { + profiler.push("citresewn:disposing"); + if (active != null) { + active.dispose(); + active = null; + } + + ActiveCITs active = new ActiveCITs(); + + profiler.swap("citresewn:load_global_properties"); + PackParser.loadGlobalProperties(resourceManager, active.globalProperties); + active.globalProperties.callHandlers(); + profiler.pop(); + + return ActiveCITs.active = active; + } + + @Override + public void dispose() { + for (Disposable disposable : FabricLoader.getInstance().getEntrypoints(Disposable.ENTRYPOINT, Disposable.class)) + disposable.dispose(); + + + } +} diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CIT.java new file mode 100644 index 0000000..ee293ce --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CIT.java @@ -0,0 +1,17 @@ +package shcm.shsupercm.fabric.citresewn.pack.cit; + +import net.minecraft.util.Identifier; + +public class CIT { + private final Identifier propertiesIdentifier; + private final String packName; + private final CITType type; + private final CITCondition[] conditions; + + public CIT(Identifier propertiesIdentifier, String packName, CITType type, CITCondition[] conditions) { + this.propertiesIdentifier = propertiesIdentifier; + this.packName = packName; + this.type = type; + this.conditions = conditions; + } +} 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 new file mode 100644 index 0000000..736afac --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITCondition.java @@ -0,0 +1,9 @@ +package shcm.shsupercm.fabric.citresewn.pack.cit; + +import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue; + +public abstract class CITCondition { + public abstract void load(String keyMetadata, PropertyValue value) throws Exception; + + 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 new file mode 100644 index 0000000..a4e0d11 --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITContext.java @@ -0,0 +1,4 @@ +package shcm.shsupercm.fabric.citresewn.pack.cit; + +public record CITContext() { +} 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 new file mode 100644 index 0000000..c10e29f --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITType.java @@ -0,0 +1,4 @@ +package shcm.shsupercm.fabric.citresewn.pack.cit; + +public abstract class CITType { +} -- cgit