summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-09-01 11:04:48 +1000
committermd_5 <git@md-5.net>2018-09-01 11:04:48 +1000
commit4c219e2a1206225cff4b34669c00106b1c312991 (patch)
tree8af1f563fddea26ab13ad7f0207b9848fde52577 /nms-patches
parent6304ccd95fc9498960e99f96b59479dfc08b3c8d (diff)
downloadcraftbukkit-4c219e2a1206225cff4b34669c00106b1c312991.tar
craftbukkit-4c219e2a1206225cff4b34669c00106b1c312991.tar.gz
craftbukkit-4c219e2a1206225cff4b34669c00106b1c312991.tar.lz
craftbukkit-4c219e2a1206225cff4b34669c00106b1c312991.tar.xz
craftbukkit-4c219e2a1206225cff4b34669c00106b1c312991.zip
Expand Recipe API to allow multiple Materials per slot
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/ShapedRecipes.patch17
-rw-r--r--nms-patches/ShapelessRecipes.patch17
2 files changed, 24 insertions, 10 deletions
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<org.bukkit.Material> 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<org.bukkit.Material> 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);
}