Skip to content

Cardinal Components has too much global state #55

Open

Description

@LoganDark

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.

Activity

  1. LoganDark commented on Mar 25, 2022

    @LoganDark
    Author

    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?

  2. Redfan2 commented on Oct 26, 2023

    @Redfan2
    Member

    If this is still a problem for you, feel free to create a fork with the proposed features

  3. LoganDark commented on Oct 26, 2023

    @LoganDark
    Author

    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.

  4. Pyrofab commented on Oct 26, 2023

    @Pyrofab
    Member

    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).

  5. LoganDark commented on Oct 26, 2023

    @LoganDark
    Author

    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)

  6. Redfan2 commented on Oct 26, 2023

    @Redfan2
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions