fix configurable daylight cycle not working (#1788)

This commit is contained in:
Amine Kacimi
2026-06-21 22:04:38 +01:00
committed by GitHub
parent 47a714c82c
commit 335be8910e
3 changed files with 18 additions and 33 deletions

View File

@@ -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();
}
}