aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-03-04 10:59:46 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-03-04 11:16:52 +0200
commitd5e4cfdad93267d7c3f574451a4ee7e0b4ef4098 (patch)
treea1e4dd7970db23aaa4804af0b75391d1c6d49b3b
parentbadaaeaae77bb8bc74b4e08cbce1087c68252914 (diff)
downloadCITResewn-d5e4cfdad93267d7c3f574451a4ee7e0b4ef4098.tar.gz
CITResewn-d5e4cfdad93267d7c3f574451a4ee7e0b4ef4098.tar.bz2
CITResewn-d5e4cfdad93267d7c3f574451a4ee7e0b4ef4098.zip
Fixed cit parsing with config not enabled
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java17
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java3
2 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
index c7ca38c..2c31641 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
@@ -5,6 +5,7 @@ import net.minecraft.resource.ResourceManager;
import net.minecraft.util.profiler.Profiler;
import shcm.shsupercm.fabric.citresewn.api.CITDisposable;
import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer;
+import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import shcm.shsupercm.fabric.citresewn.pack.GlobalProperties;
import shcm.shsupercm.fabric.citresewn.pack.PackParser;
@@ -32,14 +33,19 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
active = null;
}
+ if (!CITResewnConfig.INSTANCE.enabled) {
+ profiler.pop();
+ return null;
+ }
+
ActiveCITs active = new ActiveCITs();
profiler.swap("citresewn:load_global_properties");
- PackParser.loadGlobalProperties(resourceManager, active.globalProperties);
- active.globalProperties.callHandlers();
+ PackParser.loadGlobalProperties(resourceManager, active.globalProperties).callHandlers();
profiler.swap("citresewn:load_cits");
- for (CIT<?> cit : PackParser.loadCITs(resourceManager))
+ List<CIT<?>> cits = PackParser.loadCITs(resourceManager);
+ for (CIT<?> cit : cits)
active.cits.computeIfAbsent(cit.type.getClass(), type -> new ArrayList<>()).add(cit);
for (Map.Entry<Class<? extends CITType>, List<CIT<?>>> entry : active.cits.entrySet()) {
entry.getValue().sort(Comparator.<CIT<?>>comparingInt(cit -> cit.weight).reversed().thenComparing(cit -> cit.propertiesIdentifier.toString()));
@@ -52,7 +58,10 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
profiler.pop();
- return ActiveCITs.active = active;
+ if (!cits.isEmpty())
+ ActiveCITs.active = active;
+
+ return ActiveCITs.active;
}
@Override
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
index 163435b..794977d 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
@@ -43,7 +43,7 @@ public class PackParser {
});
}
- public static void loadGlobalProperties(ResourceManager resourceManager, GlobalProperties globalProperties) {
+ public static GlobalProperties loadGlobalProperties(ResourceManager resourceManager, GlobalProperties globalProperties) {
forEachPack(resourceManager, pack -> {
for (String root : ROOTS) {
Identifier identifier = new Identifier("minecraft", root + "/cit.properties");
@@ -56,6 +56,7 @@ public class PackParser {
}
}
});
+ return globalProperties;
}
public static List<CIT<?>> loadCITs(ResourceManager resourceManager) {