Skip to content

Commit 9460497

Browse files
authored
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
1 parent caa4780 commit 9460497

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

patches/api/0154-Implement-furnace-cook-speed-multiplier-API.patch

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,27 @@ index c5a8c96fa2204d6b4d2409b1bfc97697d39d964e..9063cf370a0fe66c2a27086e125f9111
3636
@NotNull
3737
@Override
3838
public FurnaceInventory getInventory();
39+
diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
40+
index 533a33dbd4c4c3c07fe759206dc288efec5cd531..f13f1b4daa99fb86b60acc94d0406dcd8cb4d98b 100644
41+
--- a/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
42+
+++ b/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java
43+
@@ -13,11 +13,18 @@ public class FurnaceStartSmeltEvent extends BlockEvent {
44+
private final CookingRecipe<?> recipe;
45+
private int totalCookTime;
46+
47+
+ @Deprecated // Paper - furnace cook speed multiplier
48+
public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull final CookingRecipe<?> recipe) {
49+
+ // Paper start - furnace cook speed multiplier
50+
+ this(furnace, source, recipe, recipe.getCookingTime());
51+
+ }
52+
+
53+
+ public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull CookingRecipe<?> recipe, int cookingTime) {
54+
+ // Paper end
55+
super(furnace);
56+
this.source = source;
57+
this.recipe = recipe;
58+
- this.totalCookTime = recipe.getCookingTime();
59+
+ this.totalCookTime = cookingTime; // Paper - furnace cook speed multiplier
60+
}
61+
62+
/**

patches/server/0270-Implement-furnace-cook-speed-multiplier-API.patch

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ to the nearest Integer when updating its current cook time.
1111
Modified by: Eric Su <ericsu@alumni.usc.edu>
1212

1313
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
14-
index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..348196524eb3770541966e7e842ff0ae7afd94ad 100644
14+
index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..02ded982bc36ce6530c92e18a079dc0bec729273 100644
1515
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
1616
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
1717
@@ -73,6 +73,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -42,6 +42,15 @@ index 265fa3cb96b7d39194a7e83b8b77b811bc3e8b40..348196524eb3770541966e7e842ff0ae
4242
ContainerHelper.saveAllItems(nbt, this.items);
4343
CompoundTag nbttagcompound1 = new CompoundTag();
4444

45+
@@ -346,7 +353,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
46+
CraftItemStack source = CraftItemStack.asCraftMirror(blockEntity.items.get(0));
47+
CookingRecipe<?> recipe = (CookingRecipe<?>) irecipe.toBukkitRecipe();
48+
49+
- FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, pos), source, recipe);
50+
+ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, pos), source, recipe, AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity.recipeType, blockEntity, blockEntity.cookSpeedMultiplier)); // Paper - cook speed multiplier API
51+
world.getCraftServer().getPluginManager().callEvent(event);
52+
53+
blockEntity.cookingTotalTime = event.getTotalCookTime();
4554
@@ -354,9 +361,9 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
4655
// CraftBukkit end
4756

0 commit comments

Comments
 (0)