-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support the live daylight cycle #571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for taking the time to make a PR!
Unfortunately you didn't speak to me about this before implementing it, because i don't think bluemap is ready for this feature yet.. let me explain:
What i really don't like about this is the need to have yet another additional constant request-spam to the webserver for each update.
This is already something i want to change about the player/marker updates.
The plan is to eventually switch to a websocket/SSE based updating, with possibly a fallback to a single live-data request interface for all updates -> markers, players and additional updates like this daylight thing.
With that we can then have a lot more live-updates a lot faster without spamming too many http-requests ^^'
For this reason I want to finish that websocket/SSE switch first, before adding any more live updates on the webapp.
Additionally there is plans to completely rewrite the webapp etc.. all which is tied tightly together with SOO many ideas i have and want to implement. The issue is that most of those ideas and plans i have not written down anywhere ^^' Which is my fault, but it basically makes it impossible for someone to make a PR for bluemap that doesn't clash with any of my plans :/
if (!fileData || !fileData.brightness) { | ||
reject("Failed to parse brightness.json"); | ||
} | ||
let world_name = this.mapViewer.map.data.name.match(/\(([^)]+)\)/)[1].toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The map-name can be changed and is not at all guaranteed to include the world-id/dimension, so we can't use this to identify the dimension-key of a map
@@ -99,6 +101,9 @@ default Optional<ServerWorld> getServerWorld(Object world) { | |||
@DebugDump | |||
Collection<Player> getOnlinePlayers(); | |||
|
|||
@DebugDump | |||
Map<Key, Integer> getSkyBrightness(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be something like a int getSkyBrightness()
or maybe even int getWorldTime()
in the ServerWorld
interface instead
Introduction
Thank you for your amazing project. BlueMap helps me a lot!
Just noticed that the feature is in Ideas board, so I try to implement it. #398
These changes implement the feature of a live daylight cycle on BlueMap webpages. I leverage the Minecraft API to get the ambient darkness of all dimensions and add an HTTP handler to allow frontend to retrieve this data.
Demo
Details
forge
andneoforge
sides, I utilizedlevel.getSkyDarken()
to get ambient darkness data. This method returns an integer ranging from 0 to 11, where 0 means day and 11 means night.fabric
side is similar to theforge
side; I usedworld.getAmbientDarkness()
, which has the same effect asgetSkyDarken()
.spigot
andsponge
sides, I couldn't find a similar function, so I used ticks and some hardcoding to implement the feature.SettingsMenu
. Users can toggle this button to turn the feature on or off. The frontend will request/live/brightness.json
every 2 seconds (or every 3 seconds if the request fails) and adjust thesunlightStrength
value accordingly. The data format is as follows:Test coverage
I tested forge, fabric, paper, and sponge on versions 1.19-1.20, and the feature works well. I can make more tests if you think this PR would be helpful for you.
If you find any errors or shortcomings in these changes, I will fix them as soon as possible! And the branch is allow edits by maintainers, you can make any improvement.