This "java.lang.IllegalArgumentException: Comparison method violates its general contract!" error at net.minecraft.server.CraftingManager.sort(CraftingManager.java:114) is very strange, and is affecting several of my plugins – most which (ab)use enchantments on recipes for their own use. QuickBench specifically adds the book + crafting table = crafting-table-with-enchantments recipe, which apparently destabilizes the recipe sorting. Haven't seen this problem on vanilla CraftBukkits, so maybe introduced by Forge or other mods, not really sure.
IC2 and RP2 add their own recipe type, which net.minecraft.server.RecipeSorter's compare() doesn't recognize:
Spoiler 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);
}
The comparison then falls through, and considers all non-shaped/shapeless recipes to be equal, as long as they have the same size:
Spoiler22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@15e1e8de
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@69e668ab
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@4b8ae67a
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs ic2.common.AdvRecipe@eec2e6e
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@428367ab
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@42f7a074
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@d257ecd
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@3f5fc55e
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@275265d
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@afe1837
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@74224c87
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@2aace7a7
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@3e6d7c3d
22:30:26 [INFO] ret 0 since 9 vs 9
22:30:26 [INFO] compare net.minecraft.server.ShapedRecipes@5d4390ac vs net.minecraft.server.ShapedRecipes@5b14fb0a
22:30:26 [INFO] ret 0 since 9 vs 9
java.lang.IllegalArgumentException: Comparison method violates its general contract!
Patching net.minecraft.server.RecipeSorter() is an option.. but it isn't even touched by CraftBukkit yet, so it'd have to be added..
But here's a quick workaround you can try:
https://github.com/downloads/mushroomhostage/QuickBench/CraftingManager.classreplace net/minecraft/server/CraftingManager.class with this file in craftbukkit-1.2.5-R1.3-MCPC-SNAPSHOT-87.jar (may or may not work with later builds depending on if
this file changes), and then recipe sorting will be disabled (
source).
This should fix any sorting problems. The downside? From what I can tell, sorting recipes is a performance optimization.. it tries to sort shapeless recipes first, smaller recipes first, so that the linear iteration in craft() finds smaller recipes faster (wild guess). But I don't know how significant this optimization is – with the patch, I'm not seeing any noticeable slowdown when crafting or opening a QuickBench. YMMV, but let me know
update: this "Comparison method violates its general contract!" error should now be fixed in MCPC build #132+ – if you still see it, please let me know