mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
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:
parent
7ab005b9c2
commit
403d07e954
2 changed files with 33 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue