Skip to content

Commit e04b05d

Browse files
committed
Don't return null for models we claim are in the faked model registry
1 parent 14170ad commit e04b05d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.google.common.graph.GraphBuilder;
77
import com.google.common.graph.MutableGraph;
88
import net.minecraft.client.resources.model.BakedModel;
9+
import net.minecraft.client.resources.model.ModelBakery;
910
import net.minecraft.resources.ResourceLocation;
1011
import net.minecraft.world.item.Item;
1112
import net.minecraft.world.level.block.Block;
@@ -14,6 +15,7 @@
1415
import net.minecraftforge.fml.ModList;
1516
import net.minecraftforge.forgespi.language.IModInfo;
1617
import net.minecraftforge.registries.ForgeRegistries;
18+
import org.embeddedt.modernfix.ModernFix;
1719
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
1820
import org.jetbrains.annotations.Nullable;
1921

@@ -69,12 +71,23 @@ public Map<ResourceLocation, BakedModel> wrapRegistry(String modId) {
6971
if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains))
7072
return this.modelRegistry;
7173
Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace()));
74+
BakedModel missingModel = modelRegistry.get(ModelBakery.MISSING_MODEL_LOCATION);
7275
return new ForwardingMap<ResourceLocation, BakedModel>() {
7376
@Override
7477
protected Map<ResourceLocation, BakedModel> delegate() {
7578
return modelRegistry;
7679
}
7780

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+
7891
@Override
7992
public Set<ResourceLocation> keySet() {
8093
return ourModelLocations;

0 commit comments

Comments
 (0)