Archiviert
13
0

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

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-10-27 15:04:32 +00:00 committet von GitHub
Ursprung ecb4ccd633
Commit c712f2c053
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -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
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
+++ 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();
int i = 0;
@ -43,6 +43,9 @@ index 7ba4196a9e71085c35e732b5440db3109121b195..213e8cf55c3e1aeefc77729b872763bb
- return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null);
+ // Paper start
+ if (matchedProvided.isEmpty() || matchedIngredients.isEmpty()) {
+ return false;
+ }
+ java.util.List<RecipeItemStack> ingredients = new java.util.ArrayList<>(this.ingredients);
+ 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)));