Use wall time instead of ticks for several things. Fixes BUKKIT-4059
Currently furnace smelting and the item pickup delay timer use wall time (aka actual time passed) to emulate a constant tick rate so run at the same speed regardless of the server's actual tick rate. There are several other places this makes sense so this commit converts them. The item despawn timer is converted so now always takes 5 minutes. Users know this 5 minute number well so keeping this constant helps to avoid confusion. This also helps alleviate lag because if a large number of item drops is the reason your server is running slowly having them stay around longer just means your server is slow longer. Potion brewing and the zombie villager conversion timer are now constant. These match the furnace criteria of being useful for hiding lag and not having a detrimental effect on gameplay. Potion effects are now also using wall time. The client is told about effect times in ticks and displays this information to the user as minutes and seconds assuming a solid 20 ticks per second. The server does have code for updating the client with the current time remaining to help avoid skew due to differing tick rates but making this a constant makes sense due to this display.
This commit is contained in:
committed by
Wesley Wolfe
parent
94f43d8c36
commit
1c18834b7d
@@ -10,7 +10,7 @@ public class EntityItem extends Entity {
|
||||
public int pickupDelay;
|
||||
private int d;
|
||||
public float c;
|
||||
private int lastTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
private int lastTick = MinecraftServer.currentTick; // CraftBukkit
|
||||
|
||||
public EntityItem(World world, double d0, double d1, double d2) {
|
||||
super(world);
|
||||
@@ -55,10 +55,11 @@ public class EntityItem extends Entity {
|
||||
|
||||
public void l_() {
|
||||
super.l_();
|
||||
// CraftBukkit start
|
||||
int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
this.pickupDelay -= (currentTick - this.lastTick);
|
||||
this.lastTick = currentTick;
|
||||
// CraftBukkit start - Use wall time for pickup and despawn timers
|
||||
int elapsedTicks = Math.max(1, MinecraftServer.currentTick - this.lastTick);
|
||||
this.pickupDelay -= elapsedTicks;
|
||||
this.age += elapsedTicks;
|
||||
this.lastTick = MinecraftServer.currentTick;
|
||||
// CraftBukkit end
|
||||
|
||||
this.lastX = this.locX;
|
||||
@@ -100,7 +101,7 @@ public class EntityItem extends Entity {
|
||||
this.motY *= -0.5D;
|
||||
}
|
||||
|
||||
++this.age;
|
||||
// ++this.age; // CraftBukkit - Moved up
|
||||
if (!this.world.isStatic && this.age >= 6000) {
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
|
||||
Reference in New Issue
Block a user