2019-07-20 06:01:24 +02:00
|
|
|
From 5015d83a985138b9e361b014247e9b1ba72ff012 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
|
2019-07-20 06:01:24 +02:00
|
|
|
index 2bbd3663a7..55b5646103 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
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -8,6 +8,7 @@ import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
2018-09-18 00:53:27 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
// CraftBukkit start
|
2019-05-05 10:33:44 +02:00
|
|
|
+import java.util.List;
|
2018-09-18 00:53:27 +02:00
|
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -26,6 +27,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
|
|
protected NonNullList<ItemStack> items;
|
|
|
|
public int burnTime;
|
2018-09-18 00:53:27 +02:00
|
|
|
private int ticksForCurrentFuel;
|
|
|
|
+ public double cookSpeedMultiplier = 1.0; // Paper - cook speed multiplier API
|
2019-05-05 10:33:44 +02:00
|
|
|
public int cookTime;
|
|
|
|
public int cookTimeTotal;
|
|
|
|
protected final IContainerProperties b;
|
|
|
|
@@ -212,6 +214,11 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
|
|
this.n.put(minecraftkey, j);
|
2018-09-18 00:53:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - cook speed API
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.CookSpeedMultiplier")) {
|
|
|
|
+ this.cookSpeedMultiplier = nbttagcompound.getDouble("Paper.CookSpeedMultiplier");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
|
|
|
@@ -220,6 +227,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
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);
|
2019-05-05 10:33:44 +02:00
|
|
|
nbttagcompound.setShort("RecipesUsedSize", (short) this.n.size());
|
2018-09-18 00:53:27 +02:00
|
|
|
int i = 0;
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -283,8 +291,8 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
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;
|
2019-05-05 10:33:44 +02:00
|
|
|
this.cookTimeTotal = this.getRecipeCookingTime();
|
2018-09-18 00:53:27 +02:00
|
|
|
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
|
2019-07-20 06:01:24 +02:00
|
|
|
index 9cc67915ca..1ce10ea049 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
|
2019-05-05 10:33:44 +02:00
|
|
|
@@ -63,4 +63,18 @@ public class CraftFurnace<T extends TileEntityFurnace> extends CraftContainer<T>
|
|
|
|
public void setCookTimeTotal(int cookTimeTotal) {
|
|
|
|
this.getSnapshot().cookTimeTotal = cookTimeTotal;
|
2018-09-18 00:53:27 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
|
|
|
}
|
|
|
|
--
|
2019-06-25 21:18:50 +02:00
|
|
|
2.22.0
|
2018-09-18 00:53:27 +02:00
|
|
|
|