mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-10 09:02:09 -07:00
Fixed furnace cook-speed multiplier losing precision when calculating cook time
This commit is contained in:
@@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
@@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
||||||
}
|
// Paper end
|
||||||
|
|
||||||
public static boolean isFuel(ItemStack itemstack) {
|
public static boolean isFuel(ItemStack itemstack) {
|
||||||
- return f().containsKey(itemstack.getItem());
|
- return f().containsKey(itemstack.getItem());
|
||||||
|
@@ -5,6 +5,11 @@ Subject: [PATCH] Implement furnace cook speed multiplier API
|
|||||||
|
|
||||||
Signed-off-by: Tassu <git@tassu.me>
|
Signed-off-by: Tassu <git@tassu.me>
|
||||||
|
|
||||||
|
Fixed an issue where a furnace's cook-speed multiplier rounds down
|
||||||
|
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/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
||||||
@@ -46,16 +51,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
@@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isBurning() && this.canBurn(irecipe)) {
|
if (this.isBurning() && this.canBurn(irecipe)) {
|
||||||
- ++this.cookTime;
|
++this.cookTime;
|
||||||
- if (this.cookTime == this.cookTimeTotal) {
|
- if (this.cookTime == this.cookTimeTotal) {
|
||||||
+ this.cookTime += cookSpeedMultiplier; // Paper - cook speed multiplier API
|
|
||||||
+ if (this.cookTime >= this.cookTimeTotal) { // Paper - cook speed multiplier API
|
+ if (this.cookTime >= this.cookTimeTotal) { // Paper - cook speed multiplier API
|
||||||
this.cookTime = 0;
|
this.cookTime = 0;
|
||||||
this.cookTimeTotal = this.getRecipeCookingTime();
|
this.cookTimeTotal = this.getRecipeCookingTime();
|
||||||
this.burn(irecipe);
|
this.burn(irecipe);
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- protected int getRecipeCookingTime() {
|
||||||
|
- return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
|
||||||
|
+ // Paper begin - Expose this function so CraftFurnace can correctly scale the total cooking time to a new multiplier
|
||||||
|
+ public int getRecipeCookingTime() {
|
||||||
|
+ /* Scale the recipe's cooking time to the current cookSpeedMultiplier */
|
||||||
|
+ int cookTime = (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
|
||||||
|
+ return (int) Math.ceil (cookTime / this.cookSpeedMultiplier);
|
||||||
|
}
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
|
public static boolean isFuel(ItemStack itemstack) {
|
||||||
|
return f().containsKey(itemstack.getItem());
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
||||||
@@ -75,7 +94,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ public void setCookSpeedMultiplier(double multiplier) {
|
+ public void setCookSpeedMultiplier(double multiplier) {
|
||||||
+ com.google.common.base.Preconditions.checkArgument(multiplier >= 0, "Furnace speed multiplier cannot be negative");
|
+ com.google.common.base.Preconditions.checkArgument(multiplier >= 0, "Furnace speed multiplier cannot be negative");
|
||||||
+ com.google.common.base.Preconditions.checkArgument(multiplier <= 200, "Furnace speed multiplier cannot more than 200");
|
+ com.google.common.base.Preconditions.checkArgument(multiplier <= 200, "Furnace speed multiplier cannot more than 200");
|
||||||
+ this.getSnapshot().cookSpeedMultiplier = multiplier;
|
+ T snapshot = this.getSnapshot();
|
||||||
|
+ snapshot.cookSpeedMultiplier = multiplier;
|
||||||
|
+ snapshot.cookTimeTotal = snapshot.getRecipeCookingTime(); // Update the snapshot's current total cook time to scale with the newly set multiplier
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user