From e56f465acd520236719c68813d3e5c68304117d1 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 25 Feb 2019 21:31:50 -0500 Subject: [PATCH] Fix Custom Shapeless Crafting Recipes Mojang implemented Shapeless different than Shaped Make shaped also support the RecipeChoice API --- ...ix-Custom-Shapeless-Crafting-Recipes.patch | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Spigot-Server-Patches/0418-Fix-Custom-Shapeless-Crafting-Recipes.patch diff --git a/Spigot-Server-Patches/0418-Fix-Custom-Shapeless-Crafting-Recipes.patch b/Spigot-Server-Patches/0418-Fix-Custom-Shapeless-Crafting-Recipes.patch new file mode 100644 index 0000000000..c1be651b3a --- /dev/null +++ b/Spigot-Server-Patches/0418-Fix-Custom-Shapeless-Crafting-Recipes.patch @@ -0,0 +1,54 @@ +From 5c3f33e9438c90516f8475769ebfb3d3e2c1ff9e Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Fri, 18 Jan 2019 00:08:15 -0500 +Subject: [PATCH] Fix Custom Shapeless Crafting Recipes + +Mojang implemented Shapeless different than Shaped + +Make shaped also support the RecipeChoice API + +diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java +index 819b4ac2da..fce3ff4b6c 100644 +--- a/src/main/java/net/minecraft/server/ShapelessRecipes.java ++++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java +@@ -59,21 +59,30 @@ public class ShapelessRecipes implements IRecipe { + if (!(iinventory instanceof InventoryCrafting)) { + return false; + } else { +- AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager(); +- int i = 0; +- ++ // Paper start - use RecipeItemStack.test ++ java.util.List provided = new java.util.ArrayList<>(); + for (int j = 0; j < iinventory.n(); ++j) { + for (int k = 0; k < iinventory.U_(); ++k) { + ItemStack itemstack = iinventory.getItem(k + j * iinventory.U_()); + + if (!itemstack.isEmpty()) { +- ++i; +- autorecipestackmanager.b(new ItemStack(itemstack.getItem())); ++ provided.add(itemstack.cloneItemStack()); + } + } + } +- +- return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null); ++ INGREDIENTS: ++ for (RecipeItemStack ingredient : ingredients) { ++ for (Iterator iterator = provided.iterator() ; iterator.hasNext() ; ) { ++ ItemStack itemStack = iterator.next(); ++ if (ingredient.test(itemStack)) { ++ iterator.remove(); ++ continue INGREDIENTS; ++ } ++ } ++ return false; ++ } ++ return true; ++ // Paper end + } + } + +-- +2.20.1 +