diff options
Diffstat (limited to 'src/main/java/shcm')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java | 17 | ||||
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java | 3 |
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) { |