Avoid exposing mods to exceptions when baking models

This commit is contained in:
embeddedt 2023-05-20 12:35:33 -04:00
parent c51d7ae641
commit 962b843199
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -13,6 +13,7 @@ import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.lang3.tuple.Triple;
import org.embeddedt.modernfix.ModernFix;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -106,7 +107,12 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
if(model != SENTINEL)
return model;
else {
model = bakery.bake((ResourceLocation)o, BlockModelRotation.X0_Y0);
try {
model = bakery.bake((ResourceLocation)o, BlockModelRotation.X0_Y0);
} catch(RuntimeException e) {
ModernFix.LOGGER.error("Exception baking {}: {}", o, e);
model = missingModel;
}
if(model == missingModel) {
// to correctly emulate the original map, we return null for missing models
permanentOverrides.put((ResourceLocation) o, null);