Skip to content

Commit 8f896f0

Browse files
committed
Limit registry wrapping to known bad mods to avoid performance issues
1 parent 45ada33 commit 8f896f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.embeddedt.modernfix.forge.dynresources;
22

33
import com.google.common.collect.ForwardingMap;
4+
import com.google.common.collect.ImmutableSet;
45
import com.google.common.collect.Sets;
56
import com.google.common.graph.GraphBuilder;
67
import com.google.common.graph.MutableGraph;
@@ -26,6 +27,8 @@
2627
* of the model registry that emulates vanilla keySet behavior.
2728
*/
2829
public class ModelBakeEventHelper {
30+
// TODO: make into config option
31+
private static final Set<String> INCOMPATIBLE_MODS = ImmutableSet.of("industrialforegoing");
2932
private final Map<ResourceLocation, BakedModel> modelRegistry;
3033
private final Set<ResourceLocation> topLevelModelLocations;
3134
private final MutableGraph<String> dependencyGraph;
@@ -43,6 +46,9 @@ public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
4346
this.dependencyGraph = GraphBuilder.undirected().build();
4447
ModList.get().forEachModContainer((id, mc) -> {
4548
this.dependencyGraph.addNode(id);
49+
for(IModInfo.ModVersion version : mc.getModInfo().getDependencies()) {
50+
this.dependencyGraph.addNode(version.getModId());
51+
}
4652
});
4753
for(String id : this.dependencyGraph.nodes()) {
4854
Optional<? extends ModContainer> mContainer = ModList.get().getModContainerById(id);
@@ -61,6 +67,8 @@ public Map<ResourceLocation, BakedModel> wrapRegistry(String modId) {
6167
modIdsToInclude.addAll(this.dependencyGraph.adjacentNodes(modId));
6268
} catch(IllegalArgumentException ignored) { /* sanity check */ }
6369
modIdsToInclude.remove("minecraft");
70+
if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains))
71+
return this.modelRegistry;
6472
Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace()));
6573
return new ForwardingMap<ResourceLocation, BakedModel>() {
6674
@Override

0 commit comments

Comments
 (0)