diff options
Diffstat (limited to 'defaults/src/main/java/shcm/shsupercm/fabric')
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(); } |