[1.16] Improve performance of matching ingredients for shapeless recipes (#4694)

This commit is contained in:
Andrew Steinborn 2020-10-27 15:04:32 +00:00
parent 7811aecad6
commit 51ed2d9d21

View File

@ -43,6 +43,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null); - return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null);
+ // Paper start + // Paper start
+ if (matchedProvided.isEmpty() || matchedIngredients.isEmpty()) {
+ return false;
+ }
+ java.util.List<RecipeItemStack> ingredients = new java.util.ArrayList<>(this.ingredients); + java.util.List<RecipeItemStack> ingredients = new java.util.ArrayList<>(this.ingredients);
+ providedItems.sort(java.util.Comparator.comparingInt((ItemStack c) -> (int) matchedProvided.getCount(c)).reversed()); + providedItems.sort(java.util.Comparator.comparingInt((ItemStack c) -> (int) matchedProvided.getCount(c)).reversed());
+ ingredients.sort(java.util.Comparator.comparingInt((RecipeItemStack c) -> (int) matchedIngredients.getCount(c))); + ingredients.sort(java.util.Comparator.comparingInt((RecipeItemStack c) -> (int) matchedIngredients.getCount(c)));