Fix comparison stability of the Recipe Sorter with unknown recipes #2962 (#3030)

This commit is contained in:
mezz 2016-06-25 14:13:24 -07:00 committed by cpw
parent dd3c3a249e
commit fde90973c3

View file

@ -157,12 +157,18 @@ public class RecipeSorter implements Comparator<IRecipe>
{
Category c1 = getCategory(r1);
Category c2 = getCategory(r2);
if (c1 == SHAPELESS && c2 == SHAPED) return 1;
if (c1 == SHAPED && c2 == SHAPELESS) return -1;
int categoryComparison = -c1.compareTo(c2);
if (categoryComparison != 0)
{
return categoryComparison;
}
else
{
if (r2.getRecipeSize() < r1.getRecipeSize()) return -1;
if (r2.getRecipeSize() > r1.getRecipeSize()) return 1;
return getPriority(r2) - getPriority(r1); // high priority value first!
}
}
private static Set<Class<?>> warned = Sets.newHashSet();
public static void sortCraftManager()