From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tassu Date: Thu, 13 Sep 2018 08:45:21 +0300 Subject: [PATCH] Implement furnace cook speed multiplier API Signed-off-by: Tassu diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -0,0 +0,0 @@ import java.util.List; import java.util.Map; import javax.annotation.Nullable; // CraftBukkit start +import java.util.List; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I protected NonNullList items; public int burnTime; private int ticksForCurrentFuel; + public double cookSpeedMultiplier = 1.0; // Paper - cook speed multiplier API public int cookTime; public int cookTimeTotal; protected final IContainerProperties b; @@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I this.n.put(new MinecraftKey(s), nbttagcompound1.getInt(s)); } + // Paper start - cook speed API + if (nbttagcompound.hasKey("Paper.CookSpeedMultiplier")) { + this.cookSpeedMultiplier = nbttagcompound.getDouble("Paper.CookSpeedMultiplier"); + } + // Paper end } @Override @@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I nbttagcompound.setShort("BurnTime", (short) this.burnTime); nbttagcompound.setShort("CookTime", (short) this.cookTime); nbttagcompound.setShort("CookTimeTotal", (short) this.cookTimeTotal); + nbttagcompound.setDouble("Paper.CookSpeedMultiplier", this.cookSpeedMultiplier); // Paper - cook speed multiplier API ContainerUtil.a(nbttagcompound, this.items); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -0,0 +0,0 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I } if (this.isBurning() && this.canBurn(irecipe)) { - ++this.cookTime; - if (this.cookTime == this.cookTimeTotal) { + this.cookTime += cookSpeedMultiplier; // Paper - cook speed multiplier API + if (this.cookTime >= this.cookTimeTotal) { // Paper - cook speed multiplier API this.cookTime = 0; this.cookTimeTotal = this.getRecipeCookingTime(); this.burn(irecipe); 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 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -0,0 +0,0 @@ public class CraftFurnace extends CraftContainer public void setCookTimeTotal(int cookTimeTotal) { this.getSnapshot().cookTimeTotal = cookTimeTotal; } + + // Paper start - cook speed multiplier API + @Override + public double getCookSpeedMultiplier() { + return this.getSnapshot().cookSpeedMultiplier; + } + + @Override + 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 <= 200, "Furnace speed multiplier cannot more than 200"); + this.getSnapshot().cookSpeedMultiplier = multiplier; + } + // Paper end }