diff options
author | Andrew Steinborn <[email protected]> | 2020-10-27 17:14:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-27 13:14:23 -0400 |
commit | 9bc721428ff4df40b59259b712a76266e76d27be (patch) | |
tree | 2de8cb4cc94715d0a8337bb70284086bbd57ea7d | |
parent | 87de40926fc55438d5ee4658a550634d8be9dec9 (diff) | |
download | Paper-9bc721428ff4df40b59259b712a76266e76d27be.tar.gz Paper-9bc721428ff4df40b59259b712a76266e76d27be.zip |
[1.15] Improve performance of matching ingredients for shapeless recipes (#4695)
-rw-r--r-- | Spigot-Server-Patches/0342-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Spigot-Server-Patches/0342-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch b/Spigot-Server-Patches/0342-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch index 620202d82d..3b6bff7bea 100644 --- a/Spigot-Server-Patches/0342-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch +++ b/Spigot-Server-Patches/0342-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch @@ -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 fe03a35cc862d58fffa88325e34bad011a0a0ff7..fb481e65862b4aaa08e2302a517fdd8253d63812 100644 +index fe03a35cc862d58fffa88325e34bad011a0a0ff7..852e114e94665956f43232cf4a65ea1fd1d9b761 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 fe03a35cc862d58fffa88325e34bad011a0a0ff7..fb481e65862b4aaa08e2302a517fdd82 - 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))); |