Skip to content

feat: live daylight cycle — track server time with Live/Day/Night toggle#794

Closed
Apezdr wants to merge 2 commits intoBlueMap-Minecraft:masterfrom
Apezdr:feat/live-daynight-cycle
Closed

feat: live daylight cycle — track server time with Live/Day/Night toggle#794
Apezdr wants to merge 2 commits intoBlueMap-Minecraft:masterfrom
Apezdr:feat/live-daynight-cycle

Conversation

@Apezdr
Copy link
Copy Markdown

@Apezdr Apezdr commented Apr 25, 2026

Closes #398

Summary

Adds a Live lighting mode that tracks the server's in-game world time and smoothly transitions the map's sunlight to match — so the map darkens at night and brightens at noon in real time.

Live is the default mode. Users can also lock to Day or Night manually, or use a URL param to override the default for embeds.

Changes

Java

  • ServerWorld.getTimeOfDay() — new interface method returning in-game time of day (0–23999); defaults to 6000 (noon) so platforms that don't implement it stay at full day
  • Implemented on all platforms:
    • Fabric / Forge / NeoForge: getOverworldClockTime() % 24000
    • Bukkit / Paper: World.getTime()
  • LiveWorldDataSupplier — new supplier emitting {"timeOfDay": N}
  • MapRequestHandler — registers live/world.json with a 5s cache

Webapp

  • DayNightSwitch replaced with a Live | Day | Night 3-button control
  • Live mode polls live/world.json every 5s and animates sunlightStrength via a cosine curve: noon (tick 6000) → 1.0, midnight (tick 18000) → 0.25
  • ?lighting=day|night|live URL param overrides the default (live) — useful for embeds
  • Falls back silently when the endpoint is unavailable (static/read-only deploys)

Lighting curve

sunlight = 0.25 + 0.75 * max(0, (cos((tick - 6000) × 2π / 24000) + 1) / 2)
Tick Time Sunlight
0 Sunrise 0.63
6000 Noon 1.00
12000 Sunset 0.63
18000 Midnight 0.25

Apezdr added 2 commits April 24, 2026 23:35
Adds a Live lighting mode that polls the server world time every 5s and
smoothly transitions sunlightStrength to match the in-game time of day.
Live mode is the default; use ?lighting=day or ?lighting=night to override.

Java:
- ServerWorld.getTimeOfDay() interface method (default 6000/noon)
- Fabric/Forge/NeoForge: getOverworldClockTime() % 24000
- Bukkit/Paper: World.getTime()
- LiveWorldDataSupplier: emits {"timeOfDay": N} for 0-23999 range
- MapRequestHandler: registers live/world.json endpoint (5s cache)

Webapp:
- DayNightSwitch replaced with Live | Day | Night 3-button control
- Live mode polls live/world.json and animates sunlightStrength via
  cosine curve (noon tick 6000 = 1.0, midnight tick 18000 = 0.25)
- ?lighting=day|night|live URL param overrides the default (live)
- Falls back silently when endpoint is unavailable (static deploys)

Closes BlueMap-Minecraft#398
MapViewer resets sunlightStrength to skyLight (1.0) when a map finishes
loading, overwriting the initial live-time snap. Watch mapState='loaded'
and re-apply the live server time the moment that reset occurs.
@Apezdr
Copy link
Copy Markdown
Author

Apezdr commented Apr 25, 2026

May be helpful to have it also apply the default "live" view for embeds as well....and done

@TBlueF
Copy link
Copy Markdown
Member

TBlueF commented Apr 26, 2026

PR's that are low-effort and mainly developed by AI are not desired.

Additionally the webapp is currently undergoing a major rewrite, big changes to the old webapp are currently avoided. Implementing this feature is planned for after the webapp-rewrite.

I am closing this PR for the above reasons, for future PR's please follow the contributing guidelines and make sure your PR's are well designed, feature-complete and well-tested. Thank you :)

@TBlueF TBlueF closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live daylight cycle

2 participants