Skip to content

Commit

Permalink
Don't crash when unwrapping models
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaMode committed Apr 19, 2024
1 parent a734955 commit cd5d406
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 extends BakedModel> T unwrap(BakedModel model, Class<T> modelClass) {
public static <T extends BakedModel> BakedModel unwrap(BakedModel model, Class<T> modelClass) {
while (model instanceof WrapperBakedModel wrapper) {
if (modelClass.isAssignableFrom(model.getClass()))
return (T) model;
Expand All @@ -243,9 +243,7 @@ public static <T extends BakedModel> T unwrap(BakedModel model, Class<T> 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;
}
}

0 comments on commit cd5d406

Please sign in to comment.