Don't return null for models we claim are in the faked model registry
This commit is contained in:
parent
14170ade1f
commit
e04b05dcc8
|
|
@ -6,6 +6,7 @@ import com.google.common.collect.Sets;
|
||||||
import com.google.common.graph.GraphBuilder;
|
import com.google.common.graph.GraphBuilder;
|
||||||
import com.google.common.graph.MutableGraph;
|
import com.google.common.graph.MutableGraph;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
|
@ -14,6 +15,7 @@ import net.minecraftforge.fml.ModContainer;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
|
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
@ -69,12 +71,23 @@ public class ModelBakeEventHelper {
|
||||||
if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains))
|
if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains))
|
||||||
return this.modelRegistry;
|
return this.modelRegistry;
|
||||||
Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace()));
|
Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace()));
|
||||||
|
BakedModel missingModel = modelRegistry.get(ModelBakery.MISSING_MODEL_LOCATION);
|
||||||
return new ForwardingMap<ResourceLocation, BakedModel>() {
|
return new ForwardingMap<ResourceLocation, BakedModel>() {
|
||||||
@Override
|
@Override
|
||||||
protected Map<ResourceLocation, BakedModel> delegate() {
|
protected Map<ResourceLocation, BakedModel> delegate() {
|
||||||
return modelRegistry;
|
return modelRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BakedModel get(@Nullable Object key) {
|
||||||
|
BakedModel model = super.get(key);
|
||||||
|
if(model == null && key != null && modIdsToInclude.contains(((ResourceLocation)key).getNamespace())) {
|
||||||
|
ModernFix.LOGGER.warn("Model {} is missing, but was requested in model bake event. Returning missing model", key);
|
||||||
|
return missingModel;
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ResourceLocation> keySet() {
|
public Set<ResourceLocation> keySet() {
|
||||||
return ourModelLocations;
|
return ourModelLocations;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user