Skip to content

Instantly share code, notes, and snippets.

@mushroomhostage
Created May 5, 2012 05:24
Show Gist options
  • Save mushroomhostage/2600006 to your computer and use it in GitHub Desktop.
Save mushroomhostage/2600006 to your computer and use it in GitHub Desktop.
net.minecraft.server.RecipeSorter - java.lang.IllegalArgumentException: Comparison method violates its general contract!
public int a(CraftingRecipe craftingrecipe, CraftingRecipe craftingrecipe1)
{
if((craftingrecipe instanceof ShapelessRecipes) && (craftingrecipe1 instanceof ShapedRecipes))
return 1;
if((craftingrecipe1 instanceof ShapelessRecipes) && (craftingrecipe instanceof ShapedRecipes))
return -1;
if(craftingrecipe1.a() < craftingrecipe.a())
return -1;
return craftingrecipe1.a() <= craftingrecipe.a() ? 0 : 1;
}
public volatile int compare(Object obj, Object obj1)
{
return a((CraftingRecipe)obj, (CraftingRecipe)obj1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment