aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-13 11:01:45 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-13 11:01:45 +0200
commitfe02178b220ebf57225bd092bfdb0d8b88067c33 (patch)
tree181746d9bdc746df55edc75558236fef13085b3d /src/main/java/shcm
parent49318a4452f629274e96001700006e0b4a1464a5 (diff)
downloadCITResewn-fe02178b220ebf57225bd092bfdb0d8b88067c33.tar.gz
CITResewn-fe02178b220ebf57225bd092bfdb0d8b88067c33.tar.bz2
CITResewn-fe02178b220ebf57225bd092bfdb0d8b88067c33.zip
Generified CITs to their type
Diffstat (limited to 'src/main/java/shcm')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java7
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java10
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java6
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java1
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java8
5 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
index 8c375bb..a9666d3 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
@@ -18,5 +18,10 @@ public abstract class CITTypeContainer<T extends CITType> implements CITDisposab
this.id = id;
}
- public abstract void load(List<CIT> parsedCITs);
+ public abstract void load(List<CIT<T>> parsedCITs);
+
+ @SuppressWarnings("unchecked")
+ public final void loadUntyped(List<?> parsedCITs) {
+ load((List<CIT<T>>) parsedCITs);
+ }
}
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 d24faf8..f54cc54 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
@@ -23,7 +23,7 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
public final GlobalProperties globalProperties = new GlobalProperties();
- public final Map<Class<? extends CITType>, List<CIT>> cits = new IdentityHashMap<>();
+ public final Map<Class<? extends CITType>, List<CIT<?>>> cits = new IdentityHashMap<>();
public static ActiveCITs load(ResourceManager resourceManager, Profiler profiler) {
profiler.push("citresewn:disposing");
@@ -39,13 +39,13 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
active.globalProperties.callHandlers();
profiler.swap("citresewn:load_cits");
- for (CIT cit : PackParser.loadCITs(resourceManager))
+ for (CIT<?> cit : PackParser.loadCITs(resourceManager))
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()));
+ 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()));
for (CITTypeContainer<? extends CITType> typeContainer : CITRegistry.TYPES.values())
if (typeContainer.type == entry.getKey()) {
- typeContainer.load(entry.getValue());
+ typeContainer.loadUntyped(entry.getValue());
break;
}
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java
index ea75c04..7cc5724 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CIT.java
@@ -2,14 +2,14 @@ package shcm.shsupercm.fabric.citresewn.cit;
import net.minecraft.util.Identifier;
-public class CIT {
+public class CIT<T extends CITType> {
public final Identifier propertiesIdentifier;
public final String packName;
- public final CITType type;
+ public final T type;
public final CITCondition[] conditions;
public final int weight;
- public CIT(Identifier propertiesIdentifier, String packName, CITType type, CITCondition[] conditions, int weight) {
+ public CIT(Identifier propertiesIdentifier, String packName, T type, CITCondition[] conditions, int weight) {
this.propertiesIdentifier = propertiesIdentifier;
this.packName = packName;
this.type = type;
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
index 76576ba..2d584aa 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
@@ -4,7 +4,6 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import net.fabricmc.loader.api.FabricLoader;
-import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.LiteralText;
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 35e8c87..7555866 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
@@ -57,8 +57,8 @@ public class PackParser {
});
}
- public static List<CIT> loadCITs(ResourceManager resourceManager) {
- List<CIT> cits = new ArrayList<>();
+ public static List<CIT<?>> loadCITs(ResourceManager resourceManager) {
+ List<CIT<?>> cits = new ArrayList<>();
for (String root : ROOTS)
for (Identifier identifier : resourceManager.findResources(root + "/cit", s -> s.endsWith(".properties"))) {
@@ -75,7 +75,7 @@ public class PackParser {
}
- public static CIT parseCIT(PropertyGroup properties) throws CITParsingException {
+ public static CIT<?> parseCIT(PropertyGroup properties) throws CITParsingException {
CITType citType = CITRegistry.parseType(properties);
ArrayList<CITCondition> conditions = new ArrayList<>();
@@ -108,6 +108,6 @@ public class PackParser {
citType.load(conditions, properties);
- return new CIT(properties.identifier, properties.packName, citType, conditions.toArray(new CITCondition[0]), weight.weight);
+ return new CIT<>(properties.identifier, properties.packName, citType, conditions.toArray(new CITCondition[0]), weight.weight);
}
}