|
6 | 6 | import com.google.common.graph.GraphBuilder; |
7 | 7 | import com.google.common.graph.MutableGraph; |
8 | 8 | import net.minecraft.client.resources.model.BakedModel; |
| 9 | +import net.minecraft.client.resources.model.ModelBakery; |
9 | 10 | import net.minecraft.resources.ResourceLocation; |
10 | 11 | import net.minecraft.world.item.Item; |
11 | 12 | import net.minecraft.world.level.block.Block; |
|
14 | 15 | import net.minecraftforge.fml.ModList; |
15 | 16 | import net.minecraftforge.forgespi.language.IModInfo; |
16 | 17 | import net.minecraftforge.registries.ForgeRegistries; |
| 18 | +import org.embeddedt.modernfix.ModernFix; |
17 | 19 | import org.embeddedt.modernfix.dynamicresources.ModelLocationCache; |
18 | 20 | import org.jetbrains.annotations.Nullable; |
19 | 21 |
|
@@ -69,12 +71,23 @@ public Map<ResourceLocation, BakedModel> wrapRegistry(String modId) { |
69 | 71 | if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains)) |
70 | 72 | return this.modelRegistry; |
71 | 73 | Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace())); |
| 74 | + BakedModel missingModel = modelRegistry.get(ModelBakery.MISSING_MODEL_LOCATION); |
72 | 75 | return new ForwardingMap<ResourceLocation, BakedModel>() { |
73 | 76 | @Override |
74 | 77 | protected Map<ResourceLocation, BakedModel> delegate() { |
75 | 78 | return modelRegistry; |
76 | 79 | } |
77 | 80 |
|
| 81 | + @Override |
| 82 | + public BakedModel get(@Nullable Object key) { |
| 83 | + BakedModel model = super.get(key); |
| 84 | + if(model == null && key != null && modIdsToInclude.contains(((ResourceLocation)key).getNamespace())) { |
| 85 | + ModernFix.LOGGER.warn("Model {} is missing, but was requested in model bake event. Returning missing model", key); |
| 86 | + return missingModel; |
| 87 | + } |
| 88 | + return model; |
| 89 | + } |
| 90 | + |
78 | 91 | @Override |
79 | 92 | public Set<ResourceLocation> keySet() { |
80 | 93 | return ourModelLocations; |
|
0 commit comments