summaryrefslogtreecommitdiffstats
path: root/nms-patches/FurnaceRecipe.patch
blob: a26f71d915e9e7d58471cf4e8b742d68b5353db0 (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
49
50
51
52
53
54
55
56
57
--- a/net/minecraft/server/FurnaceRecipe.java
+++ b/net/minecraft/server/FurnaceRecipe.java
@@ -2,6 +2,16 @@
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.inventory.Recipe;
+import org.bukkit.inventory.RecipeChoice;
+// CraftBukkit end
 
 public class FurnaceRecipe implements IRecipe {
 
@@ -56,6 +66,23 @@
         return this.key;
     }
 
+    @Override
+    public Recipe toBukkitRecipe() {
+        CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+        RecipeItemStack list = this.ingredient;
+        list.buildChoices();
+
+        List<org.bukkit.Material> choices = new ArrayList<>(list.choices.length);
+        for (ItemStack i : list.choices) {
+            choices.add(CraftMagicNumbers.getMaterial(i.getItem()));
+        }
+
+        CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, new RecipeChoice.MaterialChoice(choices), this.experience, this.cookingTime);
+        recipe.setGroup(this.group);
+
+        return recipe;
+    }
+
     public static class a implements RecipeSerializer<FurnaceRecipe> {
 
         public a() {}
@@ -106,11 +133,11 @@
             return "smelting";
         }
 
-        public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
+        public FurnaceRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error
             return this.b(minecraftkey, packetdataserializer);
         }
 
-        public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) {
+        public FurnaceRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error
             return this.b(minecraftkey, jsonobject);
         }
     }