valence-rs / valence

A Rust framework for building Minecraft servers.
http://valence.rs/
MIT License
2.77k stars 142 forks source link

Optional component for `Instance` used to control time, weather, world border, etc. #210

Open rj00a opened 1 year ago

rj00a commented 1 year ago

It would be convenient if Instance had some optional components for controlling state which is typically expected to be global to the instance. This includes the time of day, whether or not time is paused (doDaylightCycle), The world border for the instance, the weather (raining or thundering), etc.

My current thinking is that we can have the following components:

Might be more convenient to make these components smaller for the purpose of change detection. Not sure.

rj00a commented 1 year ago

Might be more convenient to make these components smaller for the purpose of change detection.

Yes, each field that needs change detection should be its own component. Bundles can be used to make this more convenient.

arseeeeN commented 1 year ago

How should doDaylightCycle be implemented? Should gamerules in general just be attached to the instance or should they be entities?

dyc3 commented 1 year ago

I'd consider that to be vanilla functionality, which would be out of scope for valence. Do gamerules get conveyed to clients and affect them in any way? If not, gamerules are definitely out of scope.

arseeeeN commented 1 year ago

That makes sense, so the developers that use Valence would handle the updating of the time of day themselves? Including sending that information to the players of course. Should the time of day be a field of the InstanceInfo struct or a component that could be spawned alongside the entity of the Instance component?

dyc3 commented 1 year ago

Valence would be the one sending packets. As the issue says, the desired solution is a TimeOfDay component that goes on the entity that has the Instance. A system inside valence would then be able to handle sending those packets.

Weather is already implemented, you can use that for reference.

MrlnHi commented 1 year ago

I'd consider that to be vanilla functionality, which would be out of scope for valence. Do gamerules get conveyed to clients and affect them in any way? If not, gamerules are definitely out of scope.

reducedDebugScreen or however it's called gets conveyed to clients (and actually makes a difference). Other than that I can't think of any tho

tachibanayui commented 1 year ago

Is anyone already working on time of day? I want to take a shot at implementing it.

arseeeeN commented 1 year ago

I initially wanted to work on it but couldn't find the time, so feel free to take over.

1bacon commented 10 months ago

I'd consider that to be vanilla functionality, which would be out of scope for valence. Do gamerules get conveyed to clients and affect them in any way? If not, gamerules are definitely out of scope.

reducedDebugScreen or however it's called gets conveyed to clients (and actually makes a difference). Other than that I can't think of any tho

For completeness: Only reducedDebugInfo, doLimitedCrafting and doImmediateRespawn are sent to the Client.

All others are checked by the server internally.