Prevent effects of tickrate degradation on furnaces

This commit is contained in:
Erik Broes 2011-05-01 19:26:47 +02:00
parent 029ca3e2f6
commit 8b49a945c2

View File

@ -8,6 +8,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
public int cookTime = 0; public int cookTime = 0;
// CraftBukkit start // CraftBukkit start
private int lastTick = (int) (System.currentTimeMillis() / 50);
public ItemStack[] getContents() { public ItemStack[] getContents() {
return items; return items;
} }
@ -106,13 +107,22 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
boolean flag = this.burnTime > 0; boolean flag = this.burnTime > 0;
boolean flag1 = false; boolean flag1 = false;
// CraftBukkit start
int currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
int elapsedTicks = currentTick - this.lastTick;
this.lastTick = currentTick;
// CraftBukkit end
if (this.burnTime > 0) { if (this.burnTime > 0) {
--this.burnTime; this.burnTime -= elapsedTicks; // CraftBukkit
} }
if (!this.world.isStatic) { if (!this.world.isStatic) {
if (this.burnTime == 0 && this.h()) { // CraftBukkit start -- handle multiple elapsed ticks
this.b = this.burnTime = this.a(this.items[1]); if (this.burnTime <= 0 && this.h()) { // CraftBukkit == to <=
this.b = this.a(this.items[1]);
this.burnTime += this.b;
// CraftBukkit end
if (this.burnTime > 0) { if (this.burnTime > 0) {
flag1 = true; flag1 = true;
if (this.items[1] != null) { if (this.items[1] != null) {
@ -125,9 +135,11 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
} }
if (this.f() && this.h()) { if (this.f() && this.h()) {
++this.cookTime; // CraftBukkit start -- handle multiple elapsed ticks
if (this.cookTime == 200) { this.cookTime += elapsedTicks;
this.cookTime = 0; if (this.cookTime >= 200) {
this.cookTime %= 200;
// CraftBukkit end
this.g(); this.g();
flag1 = true; flag1 = true;
} }