PaperMC/patches/unapplied/server/0606-Add-recipe-to-cook-events.patch

45 lines
3.5 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
Date: Wed, 6 Jan 2021 12:04:03 -0800
Subject: [PATCH] Add recipe to cook events
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
2022-03-01 06:43:03 +01:00
index e62fa09ca481183be2ee158b0717172c90de1b92..18eff3a00ae5137ec71c31bc3466a864c60d9fde 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
2022-03-01 06:43:03 +01:00
@@ -427,7 +427,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
2021-06-11 14:02:28 +02:00
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
2021-06-15 04:59:31 +02:00
- FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result);
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result, (org.bukkit.inventory.CookingRecipe<?>) irecipe.toBukkitRecipe()); // Paper
world.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent);
2021-06-11 14:02:28 +02:00
if (furnaceSmeltEvent.isCancelled()) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
2022-03-01 06:43:03 +01:00
index 02cdd957e7f79f6c00ee015a0d382def8aa2aead..1d2dbaec8201de12fb65e2c01ca8a1ead7e873a7 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
2021-11-24 21:15:19 +01:00
@@ -52,7 +52,10 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
2021-06-11 14:02:28 +02:00
2021-06-15 04:59:31 +02:00
if (campfire.cookingProgress[i] >= campfire.cookingTime[i]) {
2021-06-11 14:02:28 +02:00
SimpleContainer inventorysubcontainer = new SimpleContainer(new ItemStack[]{itemstack});
2021-06-15 04:59:31 +02:00
- ItemStack itemstack1 = (ItemStack) world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world).map((recipecampfire) -> {
2021-06-11 14:02:28 +02:00
+ // Paper start
2021-06-15 04:59:31 +02:00
+ Optional<CampfireCookingRecipe> recipe = world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world);
2021-06-11 14:02:28 +02:00
+ ItemStack itemstack1 = (ItemStack) recipe.map((recipecampfire) -> {
+ // Paper end
return recipecampfire.assemble(inventorysubcontainer);
}).orElse(itemstack);
2021-06-15 04:59:31 +02:00
2021-11-24 21:15:19 +01:00
@@ -60,7 +63,7 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
2021-06-11 14:02:28 +02:00
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
2021-06-15 04:59:31 +02:00
- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result);
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper
world.getCraftServer().getPluginManager().callEvent(blockCookEvent);
2021-06-11 14:02:28 +02:00
if (blockCookEvent.isCancelled()) {