summaryrefslogtreecommitdiffstats
path: root/nms-patches/RecipeRepair.patch
blob: ab7e733106fa655a8660e9337874dcc66bc11e0f (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
--- a/net/minecraft/server/RecipeRepair.java
+++ b/net/minecraft/server/RecipeRepair.java
@@ -4,9 +4,13 @@
 import java.util.ArrayList;
 import javax.annotation.Nullable;
 
-public class RecipeRepair implements IRecipe {
+public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
 
-    public RecipeRepair() {}
+    // CraftBukkit start - Delegate to new parent class
+    public RecipeRepair() {
+        super(new ItemStack(Items.LEATHER_HELMET), java.util.Arrays.asList(new ItemStack(Items.LEATHER_HELMET)));
+    }
+    // CraftBukkit end
 
     public boolean a(InventoryCrafting inventorycrafting, World world) {
         ArrayList arraylist = Lists.newArrayList();
@@ -64,7 +68,17 @@
                     i1 = 0;
                 }
 
-                return new ItemStack(itemstack2.getItem(), 1, i1);
+                // CraftBukkit start - Construct a dummy repair recipe
+                ItemStack result = new ItemStack(itemstack.getItem(), 1, i1);
+                java.util.List<ItemStack> ingredients = new ArrayList<ItemStack>();
+                ingredients.add(itemstack2.cloneItemStack());
+                ingredients.add(itemstack.cloneItemStack());
+                ShapelessRecipes recipe = new ShapelessRecipes(result.cloneItemStack(), ingredients);
+                inventorycrafting.currentRecipe = recipe;
+                result = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, result, CraftingManager.getInstance().lastCraftView, true);
+                return result;
+                // return new ItemStack(itemstack2.getItem(), 1, i1);
+                // CraftBukkit end
             }
         }