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
This commit is contained in:
Bjarne Koll 2021-09-22 21:46:15 +02:00 committed by GitHub
parent caa4780282
commit 9460497d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View file

@ -11,7 +11,7 @@ to the nearest Integer when updating its current cook time.
Modified by: Eric Su <ericsu@alumni.usc.edu>
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
index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..348196524eb3770541966e7e842ff0ae7afd94ad 100644
index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..02ded982bc36ce6530c92e18a079dc0bec729273 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -73,6 +73,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@ -42,6 +42,15 @@ index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..348196524eb3770541966e7e842ff0ae
ContainerHelper.saveAllItems(nbt, this.items);
CompoundTag nbttagcompound1 = new CompoundTag();
@@ -346,7 +353,7 @@ 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();
@@ -354,9 +361,9 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
// CraftBukkit end