55import com .google .common .collect .Sets ;
66import com .google .common .graph .GraphBuilder ;
77import com .google .common .graph .MutableGraph ;
8+ import net .minecraft .client .renderer .block .BlockModelShaper ;
89import net .minecraft .client .resources .model .BakedModel ;
910import net .minecraft .client .resources .model .ModelBakery ;
11+ import net .minecraft .client .resources .model .ModelResourceLocation ;
1012import net .minecraft .resources .ResourceLocation ;
11- import net .minecraft .world .item .Item ;
1213import net .minecraft .world .level .block .Block ;
1314import net .minecraft .world .level .block .state .BlockState ;
1415import net .minecraftforge .fml .ModContainer ;
1516import net .minecraftforge .fml .ModList ;
1617import net .minecraftforge .forgespi .language .IModInfo ;
1718import net .minecraftforge .registries .ForgeRegistries ;
1819import org .embeddedt .modernfix .ModernFix ;
19- import org .embeddedt .modernfix .dynamicresources .ModelLocationCache ;
2020import org .embeddedt .modernfix .util .ForwardingInclDefaultsMap ;
2121import org .jetbrains .annotations .Nullable ;
2222
@@ -40,14 +40,13 @@ public class ModelBakeEventHelper {
4040 public ModelBakeEventHelper (Map <ResourceLocation , BakedModel > modelRegistry ) {
4141 this .modelRegistry = modelRegistry ;
4242 this .topLevelModelLocations = new HashSet <>(modelRegistry .keySet ());
43+ // Skip going through ModelLocationCache because most of the accesses will be misses
4344 for (Block block : ForgeRegistries .BLOCKS ) {
4445 for (BlockState state : block .getStateDefinition ().getPossibleStates ()) {
45- topLevelModelLocations .add (ModelLocationCache . get (state ));
46+ topLevelModelLocations .add (BlockModelShaper . stateToModelLocation (state ));
4647 }
4748 }
48- for (Item item : ForgeRegistries .ITEMS ) {
49- topLevelModelLocations .add (ModelLocationCache .get (item ));
50- }
49+ ForgeRegistries .ITEMS .getKeys ().forEach (key -> topLevelModelLocations .add (new ModelResourceLocation (key , "inventory" )));
5150 this .dependencyGraph = GraphBuilder .undirected ().build ();
5251 ModList .get ().forEachModContainer ((id , mc ) -> {
5352 this .dependencyGraph .addNode (id );
0 commit comments