aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java6
-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
6 files changed, 21 insertions, 17 deletions
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java
index 8e3bcbc..1b0e98e 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java
@@ -26,11 +26,11 @@ public class TypeItem extends CITType {
super(TypeItem.class, TypeItem::new, "item");
}
- public Map<Item, Set<CIT>> loaded = new IdentityHashMap<>();
+ public Map<Item, Set<CIT<TypeItem>>> loaded = new IdentityHashMap<>();
@Override
- public void load(List<CIT> parsedCITs) {
- for (CIT cit : parsedCITs)
+ public void load(List<CIT<TypeItem>> parsedCITs) {
+ for (CIT<TypeItem> cit : parsedCITs)
for (CITCondition condition : cit.conditions)
if (condition instanceof ConditionItems items)
for (Item item : items.items)
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);
}
}