From cd5d40642f6bd5f5e0f277b7531190b282f5f7c1 Mon Sep 17 00:00:00 2001 From: alpha Date: Fri, 19 Apr 2024 14:22:13 -0500 Subject: [PATCH] Don't crash when unwrapping models --- gradle.properties | 2 +- .../slimeknights/mantle/client/model/RetexturedModel.java | 2 +- .../slimeknights/mantle/client/model/util/ModelHelper.java | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6c8db264..2d5d6fa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,6 +26,6 @@ satin_version = 1.11.0 modmenu_version=7.2.1 cca_version=5.2.2 -port_lib_version = 2.2.1-beta +port_lib_version = 2.3.4 port_lib_modules = accessors,attributes,base,core,common,config,entity,extensions,models,model_loader,networking,tags,transfer,fluids,lazy_registration,loot,utility star_version = 1.5.1 diff --git a/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java b/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java index 416b7dbe..960bd13c 100644 --- a/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java @@ -298,7 +298,7 @@ public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable C } // if valid, use the block - return ModelHelper.unwrap(originalModel, Baked.class).getCachedModel(block); + return ((Baked) ModelHelper.unwrap(originalModel, Baked.class)).getCachedModel(block); } } } diff --git a/src/main/java/slimeknights/mantle/client/model/util/ModelHelper.java b/src/main/java/slimeknights/mantle/client/model/util/ModelHelper.java index 707fc934..98ce8489 100644 --- a/src/main/java/slimeknights/mantle/client/model/util/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/model/util/ModelHelper.java @@ -229,7 +229,7 @@ public static int getRotation(JsonObject json, String key) { /** * Fully unwrap a model, i.e. return the innermost model. */ - public static T unwrap(BakedModel model, Class modelClass) { + public static BakedModel unwrap(BakedModel model, Class modelClass) { while (model instanceof WrapperBakedModel wrapper) { if (modelClass.isAssignableFrom(model.getClass())) return (T) model; @@ -243,9 +243,7 @@ public static T unwrap(BakedModel model, Class modelCl model = wrapped; } } - if (!modelClass.isAssignableFrom(model.getClass())) - throw new RuntimeException("Trying to unwrap " + model + " that isn't assignable to " + modelClass); - return (T) model; + return model; } }