2018-12-23 18:04:13 +01:00
|
|
|
From 4e869dd25e33172bfeef6e9d57016dceeaf31515 Mon Sep 17 00:00:00 2001
|
2018-09-18 00:53:27 +02:00
|
|
|
From: Tassu <git@tassu.me>
|
|
|
|
Date: Thu, 13 Sep 2018 08:45:21 +0300
|
|
|
|
Subject: [PATCH] Implement furnace cook speed multiplier API
|
|
|
|
|
|
|
|
Signed-off-by: Tassu <git@tassu.me>
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2018-12-23 18:04:13 +01:00
|
|
|
index 7ec656ebe..c3c230c21 100644
|
2018-09-18 00:53:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2018-10-23 01:16:21 +02:00
|
|
|
@@ -10,6 +10,7 @@ import java.util.Map.Entry;
|
2018-09-18 00:53:27 +02:00
|
|
|
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;
|
2018-10-23 01:16:21 +02:00
|
|
|
@@ -26,6 +27,7 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
2018-09-18 00:53:27 +02:00
|
|
|
private NonNullList<ItemStack> items;
|
|
|
|
private int burnTime;
|
|
|
|
private int ticksForCurrentFuel;
|
|
|
|
+ public double cookSpeedMultiplier = 1.0; // Paper - cook speed multiplier API
|
|
|
|
private int cookTime;
|
|
|
|
private int cookTimeTotal;
|
|
|
|
private IChatBaseComponent l;
|
2018-10-23 01:16:21 +02:00
|
|
|
@@ -219,6 +221,11 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
2018-09-18 00:53:27 +02:00
|
|
|
this.l = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - cook speed API
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.CookSpeedMultiplier")) {
|
|
|
|
+ this.cookSpeedMultiplier = nbttagcompound.getDouble("Paper.CookSpeedMultiplier");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
2018-10-23 01:16:21 +02:00
|
|
|
@@ -226,6 +233,7 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
2018-09-18 00:53:27 +02:00
|
|
|
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.setShort("RecipesUsedSize", (short) this.m.size());
|
|
|
|
int i = 0;
|
2018-10-23 01:16:21 +02:00
|
|
|
@@ -300,8 +308,8 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
2018-09-18 00:53:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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.s();
|
|
|
|
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
|
2018-12-23 18:04:13 +01:00
|
|
|
index 6ca6a6bf2..cb456f726 100644
|
2018-09-18 00:53:27 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
|
2018-12-23 18:04:13 +01:00
|
|
|
@@ -74,4 +74,18 @@ public class CraftFurnace extends CraftContainer<TileEntityFurnace> implements F
|
2018-09-18 00:53:27 +02:00
|
|
|
furnace.setCustomName(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
|
|
|
}
|
|
|
|
--
|
2018-12-23 18:04:13 +01:00
|
|
|
2.20.1
|
2018-09-18 00:53:27 +02:00
|
|
|
|