[1.16] Improve performance of matching ingredients for shapeless recipes (#4694)
This commit is contained in:
parent
ecb4ccd633
commit
c712f2c053
1 changed files with 5 additions and 2 deletions
|
@ -10,10 +10,10 @@ This made the Bukkit RecipeChoice API not work for Shapeless.
|
||||||
This reimplements vanilla logic using the same test logic as Shaped
|
This reimplements vanilla logic using the same test logic as Shaped
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||||
index 7ba4196a9e71085c35e732b5440db3109121b195..213e8cf55c3e1aeefc77729b872763bbff891578 100644
|
index 7ba4196a9e71085c35e732b5440db3109121b195..61d88dbaa1f5c543be610ce0914b2c89d8ad40ee 100644
|
||||||
--- a/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
--- a/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
+++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||||
@@ -63,16 +63,46 @@ public class ShapelessRecipes implements RecipeCrafting {
|
@@ -63,16 +63,49 @@ public class ShapelessRecipes implements RecipeCrafting {
|
||||||
AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager();
|
AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ index 7ba4196a9e71085c35e732b5440db3109121b195..213e8cf55c3e1aeefc77729b872763bb
|
||||||
|
|
||||||
- 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)));
|
||||||
|
|
Loading…
Reference in a new issue