Cardinal Components has too much global state
LoganDark opened this issue ยท 6 comments
Right now, all Cardinal Components registries are completely global and only populated once. It's a simple model, but it very quickly becomes limiting.
I'm currently working on a server side-only mod that should only register components on the server (integrated server if SP). Cardinal Components only calls my entrypoint once and any components added to that registry are loaded on both the MinecraftClient and IntegratedServer. I've talked to @Pyrofab about this, and right now the best solution is to simply make your component nonfunctional on the client. But what if there was a better solution?
What if you were able to register components seperately, per client/server? What if your entrypoint wasn't just called once, but whenever a new instance sprung up with fresh registries? When the client starts, sure, but also whenever a new server starts? I present to you local state.
I believe Cardinal Components should migrate to this local state rather than global state. Registries become per-server or per-client, and your entrypoint gets called whenever a fresh registry wants data. Entrypoints can query properties on the registry to know where they are being called, and adjust their behavior accordingly. There is less forbidden sharing of data between the integrated server and Minecraft client.
Server side-only mods can opt out of registering their components on the client, while still supporting the integrated server, and not having to worry about their code being called from the wrong side. The public-facing API doesn't even need to change; you can just add new methods to the registries and clarify that the entrypoint is not called only once.
This would not only improve my development experience, but also the experience of many others who have had to deal with this problem of supporting singleplayer with single side-only mods. Your mod will rely less on static data and stay firmly planted in what matters - the server or client.
This is a tracking issue, but also a request for comment. Any feedback would be greatly appreciated.
This issue has been open for well over a year and I haven't heard anything about it in a while. @Pyrofab has the situation changed since this was opened or is it still a to-do?
If this is still a problem for you, feel free to create a fork with the proposed features
If this is still a problem for you, feel free to create a fork with the proposed features
Who are you? I don't use CCA or really create Fabric mods at all anymore.
Redfan is a member of the triage team, they must have noticed I forgot to respond to this issue in a while - to answer your question, I have not really studied the possibility yet. It's a lot of work that I can't really do myself, so it will really have to wait for someone motivated to tackle it. I did create a discussion around the V6 of CCA though, so feel free to pitch in (though I guess you may have fewer things to say if you moved away from the ecosystem).
If they are a member of the triage team , maybe they should be a member of the "Ladysnake" organization, so it is clearer that they have an affiliation with the project (rather than some random telling me "PRs welcome" after 3+ years)
If they are a member of the triage team , maybe they should be a member of the "Ladysnake" organization, so it is clearer that they have an affiliation with the project (rather than some random telling me "PRs welcome" after 3+ years)
Just looked it up, forgot to change my visibility to public after I got added to the triage Team