mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-06-23 10:47:47 +02:00
fix configurable daylight cycle not working (#1788)
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
--- a/net/minecraft/world/clock/ServerClockManager.java
|
||||
+++ b/net/minecraft/world/clock/ServerClockManager.java
|
||||
@@ -149,12 +_,12 @@
|
||||
|
||||
public ClientboundSetTimePacket createFullSyncPacket() {
|
||||
// Paper start - per-player time
|
||||
- return this.createFullSyncPacket(null);
|
||||
+ return this.createFullSyncPacket(null); // Purpur - TODO: Configurable daylight cycle
|
||||
}
|
||||
|
||||
public ClientboundSetTimePacket createFullSyncPacket(final net.minecraft.server.level.ServerPlayer player) {
|
||||
final Map<Holder<WorldClock>, ClockNetworkState> updates = new HashMap<>(this.clocks.size());
|
||||
- this.clocks.forEach((clock, instance) -> updates.put(clock, this.packNetworkState(clock, instance, player)));
|
||||
+ this.clocks.forEach((clock, instance) -> updates.put(clock, this.packNetworkState(clock, instance, player))); // Purpur - TODO: Configurable daylight cycle
|
||||
return new ClientboundSetTimePacket(this.getGameTime(), updates);
|
||||
// Paper end - per-player time
|
||||
@@ -70,7 +_,15 @@
|
||||
public void tick() {
|
||||
boolean advanceTime = this.advanceTime(); // Paper - per-world time
|
||||
if (advanceTime) {
|
||||
- this.clocks.values().forEach(ServerClockManager.ClockInstance::tick);
|
||||
+ this.clocks.forEach(((worldClockHolder, clockInstance) -> { // Purpur start - Configurable daylight cycle
|
||||
+ ServerLevel l = level != null ? level : server.overworld();
|
||||
+ int incrementTicks = 12000 / (l.isBrightOutside() ? l.purpurConfig.daytimeTicks : l.purpurConfig.nighttimeTicks);
|
||||
+ float rate = clockInstance.rate;
|
||||
+ clockInstance.rate *= incrementTicks;
|
||||
+ clockInstance.tick();
|
||||
+ clockInstance.rate = rate;
|
||||
+ this.broadcastUpdates(worldClockHolder, clockInstance);
|
||||
+ })); // Purpur end - Configurable daylight cycle
|
||||
this.setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user