From 2c82194cda350f3f978f5907ef2dc5a6433c5e5a Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:11:15 -0400 Subject: [PATCH] Fix Debark crash --- .../dynamicresources/model/DynamicModelProvider.java | 8 ++++++++ .../MixinModelLoaderEarlyViewDebark.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/embeddedt/vintagefix/dynamicresources/model/DynamicModelProvider.java b/src/main/java/org/embeddedt/vintagefix/dynamicresources/model/DynamicModelProvider.java index 0585898..17a4597 100644 --- a/src/main/java/org/embeddedt/vintagefix/dynamicresources/model/DynamicModelProvider.java +++ b/src/main/java/org/embeddedt/vintagefix/dynamicresources/model/DynamicModelProvider.java @@ -72,6 +72,14 @@ public IModel getObject(ResourceLocation location) { return opt.orElse(null); } + public IModel getModelOrMissing(ResourceLocation location) { + try { + return getObject(location); + } catch(RuntimeException e) { + return getObject(new ModelResourceLocation("builtin/missing", "missing")); + } + } + private static final Map MODEL_LOADER_REGISTRY_CACHE = ObfuscationReflectionHelper.getPrivateValue(ModelLoaderRegistry.class, null, "cache"); private static final Class VANILLA_MODEL_WRAPPER; diff --git a/src/main/java/org/embeddedt/vintagefix/mixin/dynamic_resources/MixinModelLoaderEarlyViewDebark.java b/src/main/java/org/embeddedt/vintagefix/mixin/dynamic_resources/MixinModelLoaderEarlyViewDebark.java index 9c48717..fe8bb5d 100644 --- a/src/main/java/org/embeddedt/vintagefix/mixin/dynamic_resources/MixinModelLoaderEarlyViewDebark.java +++ b/src/main/java/org/embeddedt/vintagefix/mixin/dynamic_resources/MixinModelLoaderEarlyViewDebark.java @@ -24,7 +24,7 @@ public class MixinModelLoaderEarlyViewDebark { @Inject(method = "", at = @At("RETURN") , remap = false) private void changeBackingMap(CallbackInfo ci) { - this.secretSauce = Maps.asMap(ModelLocationInformation.allKnownModelLocations, location -> DynamicModelProvider.instance.getObject(location)); + this.secretSauce = Maps.asMap(ModelLocationInformation.allKnownModelLocations, location -> DynamicModelProvider.instance.getModelOrMissing(location)); } }