From 403d07e954947ad9038142fbad002e22cb3cbd41 Mon Sep 17 00:00:00 2001 From: Bjarne Koll <32834385+lynxplay@users.noreply.github.com> Date: Wed, 22 Sep 2021 21:46:15 +0200 Subject: [PATCH] Apply furnace cook speed multiplier through event (#6378) Previously the upstream FurnaceStartSmeltEvent would default to the recipes cooking time, ignoring any modifications from the furnace speed multiplier. While this works correctly for upstream, paper introduces the speed multiplier API, which allows a different cook time from the one provided by the recipe. This commit now passes the modified cooktime to the furnace start smelt event explicitly, instead of allowing the event to default to the recipes cooking time, thus ensuring that the speed modifier is respected. Resolves: #6376 --- ...nt-furnace-cook-speed-multiplier-API.patch | 24 +++++++++++++++++++ ...nt-furnace-cook-speed-multiplier-API.patch | 9 +++++++ 2 files changed, 33 insertions(+) diff --git a/patches/api/Implement-furnace-cook-speed-multiplier-API.patch b/patches/api/Implement-furnace-cook-speed-multiplier-API.patch index b7132a7fcc..b790dfe123 100644 --- a/patches/api/Implement-furnace-cook-speed-multiplier-API.patch +++ b/patches/api/Implement-furnace-cook-speed-multiplier-API.patch @@ -36,3 +36,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @NotNull @Override public FurnaceInventory getInventory(); +diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java ++++ b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java +@@ -0,0 +0,0 @@ public class FurnaceStartSmeltEvent extends BlockEvent { + private final CookingRecipe recipe; + private int totalCookTime; + ++ @Deprecated // Paper - furnace cook speed multiplier + public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull final CookingRecipe recipe) { ++ // Paper start - furnace cook speed multiplier ++ this(furnace, source, recipe, recipe.getCookingTime()); ++ } ++ ++ public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull CookingRecipe recipe, int cookingTime) { ++ // Paper end + super(furnace); + this.source = source; + this.recipe = recipe; +- this.totalCookTime = recipe.getCookingTime(); ++ this.totalCookTime = cookingTime; // Paper - furnace cook speed multiplier + } + + /** diff --git a/patches/server/Implement-furnace-cook-speed-multiplier-API.patch b/patches/server/Implement-furnace-cook-speed-multiplier-API.patch index 6d98967ee2..33b74ed1f1 100644 --- a/patches/server/Implement-furnace-cook-speed-multiplier-API.patch +++ b/patches/server/Implement-furnace-cook-speed-multiplier-API.patch @@ -42,6 +42,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ContainerHelper.saveAllItems(nbt, this.items); CompoundTag nbttagcompound1 = new CompoundTag(); +@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit + CraftItemStack source = CraftItemStack.asCraftMirror(blockEntity.items.get(0)); + CookingRecipe recipe = (CookingRecipe) irecipe.toBukkitRecipe(); + +- FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, pos), source, recipe); ++ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, pos), source, recipe, AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity.recipeType, blockEntity, blockEntity.cookSpeedMultiplier)); // Paper - cook speed multiplier API + world.getCraftServer().getPluginManager().callEvent(event); + + blockEntity.cookingTotalTime = event.getTotalCookTime(); @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit // CraftBukkit end