aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-18 10:09:43 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-18 10:09:43 +0200
commitf90a1bc5859036e6572932fbfa05b006503c1e29 (patch)
tree992ff1f59ca66f38792da4496cc5eff183fe59e9
parent6c3eb559865c291bc363f4c9697a257c4c2cc604 (diff)
downloadCITResewn-f90a1bc5859036e6572932fbfa05b006503c1e29.tar.gz
CITResewn-f90a1bc5859036e6572932fbfa05b006503c1e29.tar.bz2
CITResewn-f90a1bc5859036e6572932fbfa05b006503c1e29.zip
Removed streams usage from item type
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java9
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java38
2 files changed, 23 insertions, 24 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 aaca882..2c431e1 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
@@ -467,21 +467,24 @@ public class TypeItem extends CITType {
super(TypeItem.class, TypeItem::new, "item");
}
- public Map<Item, Set<CIT<TypeItem>>> loaded = new IdentityHashMap<>();
+ public Set<CIT<TypeItem>> loaded = new HashSet<>();
+ public Map<Item, Set<CIT<TypeItem>>> loadedTyped = new IdentityHashMap<>();
@Override
public void load(List<CIT<TypeItem>> parsedCITs) {
+ loaded.addAll(parsedCITs);
for (CIT<TypeItem> cit : parsedCITs)
for (CITCondition condition : cit.conditions)
if (condition instanceof ConditionItems items)
for (Item item : items.items)
if (item != null)
- loaded.computeIfAbsent(item, i -> new LinkedHashSet<>()).add(cit);
+ loadedTyped.computeIfAbsent(item, i -> new LinkedHashSet<>()).add(cit);
}
@Override
public void dispose() {
loaded.clear();
+ loadedTyped.clear();
}
public CIT<TypeItem> getCIT(CITContext context, int seed) {
@@ -491,7 +494,7 @@ public class TypeItem extends CITType {
public CIT<TypeItem> getRealTimeCIT(CITContext context) {
((CITCacheItem) (Object) context.stack).citresewn$setMojankCITTypeItem(false);
- Set<CIT<TypeItem>> loadedForItemType = loaded.get(context.stack.getItem());
+ Set<CIT<TypeItem>> loadedForItemType = loadedTyped.get(context.stack.getItem());
if (loadedForItemType != null)
for (CIT<TypeItem> cit : loadedForItemType)
if (cit.test(context)) {
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
index 485268b..718cbca 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
@@ -25,6 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.cit.ActiveCITs;
+import shcm.shsupercm.fabric.citresewn.cit.CIT;
import shcm.shsupercm.fabric.citresewn.cit.CITType;
import shcm.shsupercm.fabric.citresewn.defaults.cit.types.TypeItem;
import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnItemModelIdentifier;
@@ -54,23 +55,20 @@ public class ModelLoaderMixin {
return;
info("Loading item CIT models...");
- CONTAINER.loaded.values().stream() // todo remove streams usage
- .flatMap(Collection::stream)
- .distinct().forEach(cit -> {
- try {
- cit.type.loadUnbakedAssets(resourceManager);
-
- for (JsonUnbakedModel unbakedModel : cit.type.unbakedAssets.values()) {
- ResewnItemModelIdentifier id = new ResewnItemModelIdentifier(unbakedModel.id);
- this.unbakedModels.put(id, unbakedModel);
- this.modelsToLoad.addAll(unbakedModel.getModelDependencies());
- this.modelsToBake.put(id, unbakedModel);
- }
- } catch (Exception e) {
- CITResewn.logErrorLoading("Errored loading model in " + cit.propertiesIdentifier + " from " + cit.packName);
- e.printStackTrace();
- }
- });
+ for (CIT<TypeItem> cit : CONTAINER.loaded)
+ try {
+ cit.type.loadUnbakedAssets(resourceManager);
+
+ for (JsonUnbakedModel unbakedModel : cit.type.unbakedAssets.values()) {
+ ResewnItemModelIdentifier id = new ResewnItemModelIdentifier(unbakedModel.id);
+ this.unbakedModels.put(id, unbakedModel);
+ this.modelsToLoad.addAll(unbakedModel.getModelDependencies());
+ this.modelsToBake.put(id, unbakedModel);
+ }
+ } catch (Exception e) {
+ CITResewn.logErrorLoading("Errored loading model in " + cit.propertiesIdentifier + " from " + cit.packName);
+ e.printStackTrace();
+ }
TypeItem.GENERATED_SUB_CITS_SEEN.clear();
}
@@ -83,9 +81,7 @@ public class ModelLoaderMixin {
profiler.push("citresewn:type_item_linking");
info("Linking baked models to item CITs...");
- CONTAINER.loaded.values().stream() // todo remove streams usage
- .flatMap(Collection::stream)
- .distinct().forEach(cit -> {
+ for (CIT<TypeItem> cit : CONTAINER.loaded) {
for (Map.Entry<List<ModelOverride.Condition>, JsonUnbakedModel> citModelEntry : cit.type.unbakedAssets.entrySet()) {
if (citModelEntry.getKey() == null) {
cit.type.bakedModel = this.bakedModels.get(new ResewnItemModelIdentifier(citModelEntry.getValue().id));
@@ -98,7 +94,7 @@ public class ModelLoaderMixin {
}
}
cit.type.unbakedAssets = null;
- });
+ }
profiler.pop();
}