andrewgazelka / hyperion

10,000 Player PvP. One Minecraft World. One event.
Apache License 2.0
442 stars 20 forks source link

plug-in system #466

Closed nilslice closed 1 month ago

nilslice commented 1 month ago

I see on the README that this is in progress and I'd be interested in helping out!

can you point me to a branch or file where you've started this?

andrewgazelka commented 1 month ago

I see on the README that this is in progress and I'd be interested in helping out!

can you point me to a branch or file where you've started this?

Cheers. Glad you are interested :)

Currently, we are experimenting with possible methods for achieving modularity. In flecs-land (the ECS we are using) the way they do this is using Modules (roughly equivalent to Bevy plugins). An example is here

https://github.com/andrewgazelka/hyperion/blob/efe5facdbcba6e531c002772786cb7ff352343ff/events/infection/src/block.rs#L19-L38

where we are looking at all DestroyBlock events and appropriately setting the block at that location to air (among other packet-related things... it needs a bit of refactoring). This is default behavior in Minecraft. However, we might want an event that does not have block breaking so we might not want to add on this vanilla behavior.

It is imported like so:

https://github.com/andrewgazelka/hyperion/blob/efe5facdbcba6e531c002772786cb7ff352343ff/events/infection/src/lib.rs#L32

This of course is a pure Rust module eco-system. Flecs is written in C and has bindings for other languages like C# so hypothetically could interop there some (and has been done in a production environment).

Currently there are numerous compromises this API makes, generally in terms of parallelism. I am not sure I love it. Potentially might be worth talking about it in Discord (see README) with @james-j-obrien and me.


I see you also work on https://github.com/extism . I am not too familiar with it. Do you think it would fit in well here? There are the really performance critical parts which I definitely think should be in Rust. However, maybe certain parts would play well with WASM? I am really not too sure.

nilslice commented 1 month ago

Thanks for this! I will take a look through the links you shared and jump into discord when I've got a bit more context.

Yes, actually what drew me in was recently finding another Minecraft server implemented in Rust, which already uses Extism for its plugins: https://github.com/Snowiiii/Pumpkin

I don't know yet if there's any possibility for plugin sharing, but I do think Extism would play nicely in this server. I'm excited to try it out in any case!

I'm currently moving states, so I may be a few days before I can dig in deeply - but I wanted to at least see where things were at and if I could help.

andrewgazelka commented 1 month ago

hey I am closing this as completed for now as flecs supports modules (and this is how we are structuring things). If you have any other ideas would love to talk in the Discord or respond in this issue and I can reopen it.