PaperMC/nms-patches/RecipeRepair.patch

39 lines
2 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/RecipeRepair.java
+++ b/net/minecraft/server/RecipeRepair.java
2018-07-15 02:00:00 +02:00
@@ -2,12 +2,15 @@
2016-11-17 02:41:03 +01:00
import com.google.common.collect.Lists;
import java.util.ArrayList;
2018-07-15 02:00:00 +02:00
+import java.util.stream.Stream;
2018-07-15 02:00:00 +02:00
-public class RecipeRepair extends IRecipeComplex {
2017-05-30 13:25:59 +02:00
+public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+ // CraftBukkit start - Delegate to new parent class
2018-07-15 02:00:00 +02:00
public RecipeRepair(MinecraftKey minecraftkey) {
- super(minecraftkey);
+ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET)));
}
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
public boolean a(IInventory iinventory, World world) {
if (!(iinventory instanceof InventoryCrafting)) {
@@ -71,6 +74,17 @@
ItemStack itemstack3 = new ItemStack(itemstack2.getItem());
2015-02-26 23:41:06 +01:00
2018-07-15 02:00:00 +02:00
itemstack3.setDamage(i1);
+ // CraftBukkit start - Construct a dummy repair recipe
2018-07-15 02:00:00 +02:00
+ if (iinventory instanceof InventoryCrafting) {
+ InventoryCrafting inventorycrafting = (InventoryCrafting) iinventory;
+ NonNullList<RecipeItemStack> ingredients = NonNullList.a();
+ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack2.cloneItemStack()))));
+ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack.cloneItemStack()))));
+ ShapelessRecipes recipe = new ShapelessRecipes(new MinecraftKey("repairitem"), "", itemstack3.cloneItemStack(), ingredients);
+ inventorycrafting.setCurrentRecipe(recipe);
+ itemstack3 = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycrafting.resultInventory, itemstack3, inventorycrafting.container.getBukkitView(), true);
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
return itemstack3;
}
}