Skip to content
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

Align client mod construction with server and construct before Minecraft.<init> is called #247

Open
shartte opened this issue Feb 16, 2025 · 1 comment

Comments

@shartte
Copy link
Contributor

shartte commented Feb 16, 2025

We currently construct mod objects "somewhere" inside of the constructor of Minecraft and recently moved the location for neoforged/NeoForge#1830
This caused unexpected issues due to shifting availability of some fields of Minecraft.

We should rip the bandaid off, so to speak, and align mod construction on clients with the approach taken on servers: Construct the mods much earlier (after bootstrap, but before any other global state is initialized), and offer events that align with the lifecycle of the "client" (==Minecraft), such as ClientStartingEvent, ClientStartedEvent, ClientStoppingEvent, ClientStoppedEvent.

Overall this makes the contract much clearer: During mod construction, Minecraft.instance is null, and the modder has to subscribe either to events they care about (same as now, such as RegisterClientReloadListenersEvent instead of accessing the resource manager directly), or subscribe to the client lifecycle events that make their contract much more explicit than now (are the fields of Minecraft initialized or not).

@marchermans
Copy link
Contributor

Agreed this would make stuff so much cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants