简单地说,我有以下代码,有没有更好的方法来做到这一点?
此外,我无法修改任何配方类。
public static ShapelessRecursiveRecipe convertRecipe(Object o)
{
//might be a better way to do this
if(o instanceof ShapedRecipes)
return new ShapelessRecursiveRecipe((ShapedRecipes)o);
else if(o instanceof ShapelessRecipes)
return new ShapelessRecursiveRecipe((ShapelessRecipes)o);
else if(o instanceof ShapedOreRecipe)
return new ShapelessRecursiveRecipe((ShapedOreRecipe)o);
else if(o instanceof ShapelessOreRecipe)
return new ShapelessRecursiveRecipe((ShapelessOreRecipe)o);
else
return null;
}