|
11 | 11 | import net.minecraft.client.resources.model.ModelResourceLocation; |
12 | 12 | import net.minecraft.core.registries.BuiltInRegistries; |
13 | 13 | import net.minecraft.resources.ResourceLocation; |
14 | | -import net.minecraft.world.level.block.Block; |
15 | 14 | import net.minecraft.world.level.block.state.BlockState; |
16 | 15 | import net.neoforged.fml.ModContainer; |
17 | 16 | import net.neoforged.fml.ModList; |
@@ -41,11 +40,13 @@ public class ModelBakeEventHelper { |
41 | 40 | public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) { |
42 | 41 | this.modelRegistry = modelRegistry; |
43 | 42 | this.topLevelModelLocations = new HashSet<>(modelRegistry.keySet()); |
44 | | - for(Block block : BuiltInRegistries.BLOCK) { |
45 | | - for(BlockState state : block.getStateDefinition().getPossibleStates()) { |
46 | | - topLevelModelLocations.add(BlockModelShaper.stateToModelLocation(state)); |
| 43 | + // Skip going through ModelLocationCache because most of the accesses will be misses |
| 44 | + BuiltInRegistries.BLOCK.entrySet().forEach(entry -> { |
| 45 | + var location = entry.getKey().location(); |
| 46 | + for(BlockState state : entry.getValue().getStateDefinition().getPossibleStates()) { |
| 47 | + topLevelModelLocations.add(BlockModelShaper.stateToModelLocation(location, state)); |
47 | 48 | } |
48 | | - } |
| 49 | + }); |
49 | 50 | BuiltInRegistries.ITEM.keySet().forEach(location -> topLevelModelLocations.add(new ModelResourceLocation(location, "inventory"))); |
50 | 51 | this.dependencyGraph = GraphBuilder.undirected().build(); |
51 | 52 | ModList.get().forEachModContainer((id, mc) -> { |
|
0 commit comments