summaryrefslogtreecommitdiffstats
path: root/nms-patches/ShapedRecipes.patch
blob: 9244c282ef61a83132b23622e03bbb4e8f94f9e8 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--- ../work/decompile-8eb82bde//net/minecraft/server/ShapedRecipes.java	2014-11-28 17:43:43.373707429 +0000
+++ src/main/java/net/minecraft/server/ShapedRecipes.java	2014-11-28 17:38:18.000000000 +0000
@@ -1,5 +1,11 @@
 package net.minecraft.server;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
+// CraftBukkit end
+
+
 public class ShapedRecipes implements IRecipe {
 
     private final int width;
@@ -14,6 +20,62 @@
         this.items = aitemstack;
         this.result = itemstack;
     }
+    
+    // CraftBukkit start
+    public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
+        CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+        CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
+        switch (this.height) {
+        case 1:
+            switch (this.width) {
+            case 1:
+                recipe.shape("a");
+                break;
+            case 2:
+                recipe.shape("ab");
+                break;
+            case 3:
+                recipe.shape("abc");
+                break;
+            }
+            break;
+        case 2:
+            switch (this.width) {
+            case 1:
+                recipe.shape("a","b");
+                break;
+            case 2:
+                recipe.shape("ab","cd");
+                break;
+            case 3:
+                recipe.shape("abc","def");
+                break;
+            }
+            break;
+        case 3:
+            switch (this.width) {
+            case 1:
+                recipe.shape("a","b","c");
+                break;
+            case 2:
+                recipe.shape("ab","cd","ef");
+                break;
+            case 3:
+                recipe.shape("abc","def","ghi");
+                break;
+            }
+            break;
+        }
+        char c = 'a';
+        for (ItemStack stack : this.items) {
+            if (stack != null) {
+                recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getData());
+            }
+            c++;
+        }
+        return recipe;
+    }
+    // CraftBukkit end
 
     public ItemStack b() {
         return this.result;