From 28aacb44ddccf0c072a76ad550b34455712041e9 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Tue, 22 Jun 2021 12:26:03 -0700 Subject: [PATCH] Fix NPE when setting cook multiplier (#5956) --- build-data/paper.at | 2 ++ .../0270-Implement-furnace-cook-speed-multiplier-API.patch | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index e3c2910ea..bc8ecf325 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -223,3 +223,5 @@ public net.minecraft.world.entity.animal.Fox setDefending(Z)V public net.minecraft.world.entity.animal.Fox isFaceplanted()Z public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V +# Cook speed multipler API +public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity recipeType diff --git a/patches/server/0270-Implement-furnace-cook-speed-multiplier-API.patch b/patches/server/0270-Implement-furnace-cook-speed-multiplier-API.patch index 68a9bb7ed..c2d63a863 100644 --- a/patches/server/0270-Implement-furnace-cook-speed-multiplier-API.patch +++ b/patches/server/0270-Implement-furnace-cook-speed-multiplier-API.patch @@ -11,7 +11,7 @@ to the nearest Integer when updating its current cook time. Modified by: Eric Su 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 cfa095d39843dd4963c817b824228a4b48a8c1cd..60cbb6616851758c7b8a9c90f4bb7e169358f123 100644 +index e43fd7185b4570713d8ee2361d633c94d187fe2b..6c8518cdf768bd2b613f3f2159d977d2035921c1 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 @@ -71,6 +71,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit @@ -80,7 +80,7 @@ index cfa095d39843dd4963c817b824228a4b48a8c1cd..60cbb6616851758c7b8a9c90f4bb7e16 this.setChanged(); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java -index 5028a6388f95a14df8d1590cddd7414d8de5bf78..a05704665f7718b189f0c60ae42c615fce408b0c 100644 +index 5028a6388f95a14df8d1590cddd7414d8de5bf78..92c156b09cc46e5d70ed7d803683787248495a62 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -63,4 +63,20 @@ public abstract class CraftFurnace extends @@ -100,7 +100,7 @@ index 5028a6388f95a14df8d1590cddd7414d8de5bf78..a05704665f7718b189f0c60ae42c615f + com.google.common.base.Preconditions.checkArgument(multiplier <= 200, "Furnace speed multiplier cannot more than 200"); + T snapshot = this.getSnapshot(); + snapshot.cookSpeedMultiplier = multiplier; -+ snapshot.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.world.getHandle(), snapshot.getCurrentRecipe().getType(), ((CraftInventoryFurnace) this.getInventory()).getInventory(), snapshot.cookSpeedMultiplier); // Update the snapshot's current total cook time to scale with the newly set multiplier ++ snapshot.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.world.getHandle(), snapshot.recipeType, snapshot, snapshot.cookSpeedMultiplier); // Update the snapshot's current total cook time to scale with the newly set multiplier + } + // Paper end }