mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 17:08:30 +01:00
time cleanup
This commit is contained in:
parent
9b25f0a25f
commit
f75c3870a3
@ -334,11 +334,14 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
* 18000 = midnight
|
||||
* <p>
|
||||
* This method is unaffected by {@link #getTimeRate()}
|
||||
* <p>
|
||||
* It does send the new time to all players in the instance, unaffected by {@link #getTimeUpdate()}
|
||||
*
|
||||
* @param time the new time of the instance
|
||||
*/
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
PacketWriterUtils.writeAndSend(getPlayers(), getTimePacket());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,6 +387,13 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
this.timeUpdate = timeUpdate;
|
||||
}
|
||||
|
||||
private TimeUpdatePacket getTimePacket() {
|
||||
TimeUpdatePacket timeUpdatePacket = new TimeUpdatePacket();
|
||||
timeUpdatePacket.worldAge = worldAge;
|
||||
timeUpdatePacket.timeOfDay = time;
|
||||
return timeUpdatePacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance world border
|
||||
*
|
||||
@ -756,10 +766,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
this.time += 1 * timeRate;
|
||||
|
||||
if (timeUpdate != null && !CooldownUtils.hasCooldown(time, lastTimeUpdate, timeUpdate)) {
|
||||
TimeUpdatePacket timeUpdatePacket = new TimeUpdatePacket();
|
||||
timeUpdatePacket.worldAge = worldAge;
|
||||
timeUpdatePacket.timeOfDay = this.time;
|
||||
PacketWriterUtils.writeAndSend(getPlayers(), timeUpdatePacket);
|
||||
PacketWriterUtils.writeAndSend(getPlayers(), getTimePacket());
|
||||
this.lastTimeUpdate = time;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user