summaryrefslogtreecommitdiffstats
path: root/nms-patches/ShapelessRecipes.patch
blob: 9f214f4ce5074857915a1b9368e5762c671253dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- a/net/minecraft/server/ShapelessRecipes.java
+++ b/net/minecraft/server/ShapelessRecipes.java
@@ -5,6 +5,10 @@
 import com.google.gson.JsonParseException;
 import it.unimi.dsi.fastutil.ints.IntList;
 import java.util.Iterator;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
+// CraftBukkit end
 
 public class ShapelessRecipes implements IRecipe {
 
@@ -20,6 +24,20 @@
         this.ingredients = nonnulllist;
     }
 
+    // CraftBukkit start
+    @SuppressWarnings("unchecked")
+    public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() {
+        CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+        CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
+        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);
+        }
+        return recipe;
+    }
+    // CraftBukkit end
+
     public MinecraftKey getKey() {
         return this.a;
     }
@@ -127,11 +145,11 @@
             packetdataserializer.a(shapelessrecipes.result);
         }
 
-        public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
+        public ShapelessRecipes a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error
             return this.b(minecraftkey, packetdataserializer);
         }
 
-        public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) {
+        public ShapelessRecipes a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error
             return this.b(minecraftkey, jsonobject);
         }
     }