From 4c219e2a1206225cff4b34669c00106b1c312991 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 1 Sep 2018 11:04:48 +1000 Subject: Expand Recipe API to allow multiple Materials per slot --- nms-patches/ShapedRecipes.patch | 17 ++++++++++++----- nms-patches/ShapelessRecipes.patch | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'nms-patches') diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch index e1367042..519a9f35 100644 --- a/nms-patches/ShapedRecipes.patch +++ b/nms-patches/ShapedRecipes.patch @@ -1,17 +1,20 @@ --- a/net/minecraft/server/ShapedRecipes.java +++ b/net/minecraft/server/ShapedRecipes.java -@@ -13,6 +13,10 @@ +@@ -13,6 +13,13 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; +// CraftBukkit start ++import java.util.ArrayList; ++import java.util.List; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; +// CraftBukkit end public class ShapedRecipes implements IRecipe { -@@ -32,6 +36,66 @@ +@@ -32,6 +39,70 @@ this.result = itemstack; } @@ -66,8 +69,12 @@ + for (RecipeItemStack list : this.items) { + list.buildChoices(); + if (list.choices.length > 0) { -+ net.minecraft.server.ItemStack stack = list.choices[0]; -+ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0); ++ List choices = new ArrayList<>(list.choices.length); ++ for (ItemStack i : list.choices) { ++ choices.add(CraftMagicNumbers.getMaterial(i.getItem())); ++ } ++ ++ recipe.setIngredient(c, new org.bukkit.inventory.RecipeChoice.MaterialChoice(choices)); + } + c++; + } @@ -78,7 +85,7 @@ public MinecraftKey getKey() { return this.key; } -@@ -302,11 +366,11 @@ +@@ -302,11 +373,11 @@ packetdataserializer.a(shapedrecipes.result); } diff --git a/nms-patches/ShapelessRecipes.patch b/nms-patches/ShapelessRecipes.patch index 0723cdf1..8b7e92dd 100644 --- a/nms-patches/ShapelessRecipes.patch +++ b/nms-patches/ShapelessRecipes.patch @@ -1,17 +1,20 @@ --- a/net/minecraft/server/ShapelessRecipes.java +++ b/net/minecraft/server/ShapelessRecipes.java -@@ -5,6 +5,10 @@ +@@ -5,6 +5,13 @@ import com.google.gson.JsonParseException; import it.unimi.dsi.fastutil.ints.IntList; import java.util.Iterator; +// CraftBukkit start ++import java.util.ArrayList; ++import java.util.List; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; +// CraftBukkit end public class ShapelessRecipes implements IRecipe { -@@ -20,6 +24,22 @@ +@@ -20,6 +27,26 @@ this.ingredients = nonnulllist; } @@ -24,8 +27,12 @@ + + for (RecipeItemStack list : this.ingredients) { + list.buildChoices(); -+ net.minecraft.server.ItemStack stack = list.choices[0]; -+ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0); ++ ++ List choices = new ArrayList<>(list.choices.length); ++ for (ItemStack i : list.choices) { ++ choices.add(CraftMagicNumbers.getMaterial(i.getItem())); ++ } ++ recipe.addIngredient(new org.bukkit.inventory.RecipeChoice.MaterialChoice(choices)); + } + return recipe; + } @@ -34,7 +41,7 @@ public MinecraftKey getKey() { return this.key; } -@@ -127,11 +147,11 @@ +@@ -127,11 +154,11 @@ packetdataserializer.a(shapelessrecipes.result); } -- cgit v1.2.3