Fix crash with dynamic resources if mods depend on themselves

This commit is contained in:
embeddedt 2023-07-22 11:06:11 -04:00
parent 18cec4f88d
commit 373a10f12c
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -17,10 +17,7 @@ import net.minecraftforge.registries.ForgeRegistries;
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
/**
* Stores a list of all known default block/item models in the game, and provides a namespaced version
@ -54,7 +51,9 @@ public class ModelBakeEventHelper {
Optional<? extends ModContainer> mContainer = ModList.get().getModContainerById(id);
if(mContainer.isPresent()) {
for(IModInfo.ModVersion version : mContainer.get().getModInfo().getDependencies()) {
this.dependencyGraph.putEdge(id, version.getModId());
// avoid self-loops
if(!Objects.equals(id, version.getModId()))
this.dependencyGraph.putEdge(id, version.getModId());
}
}
}