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

Prevent crashing on servers #627

Open
wants to merge 2 commits into
base: 1.20.1-new
Choose a base branch
from

Conversation

JulianVennen
Copy link

@JulianVennen JulianVennen commented May 11, 2024

When attempting to start a server with oculus installed it causes a crash because oculus attempts to access client-only code.

According to the forge documentation client-only mods should work on servers: https://docs.minecraftforge.net/en/1.20.x/concepts/sides/#writing-one-sided-mods

This PR changed oculus to only listen for events on the client and therefore prevents this kind of crash.

This supersedes #367.

@dima-dencep dima-dencep linked an issue May 14, 2024 that may be closed by this pull request
@JulianVennen
Copy link
Author

Hey, any update on this?

@dima-dencep
Copy link
Collaborator

There are unnecessary changes in this PR that I don't want to merge

@JulianVennen
Copy link
Author

Which unnecessary changes exactly are you referring to?

I think I accidentally clicked optimize imports in my IDE, which removed a few imports that were unrelated to the PR. Is that what you mean?

@Veynam
Copy link

Veynam commented Jul 23, 2024

Also waiting for updates

@JulianVennen
Copy link
Author

I rebased the changes to resolve conflicts and undid any unnecessary changes to the import.
Please let me know if there's anything else you want me to do.

@JulianVennen
Copy link
Author

Any update on this?

@dima-dencep
Copy link
Collaborator

First make a good pr that we can merge
There's a lot of unnecessary code

@JulianVennen
Copy link
Author

Please explain to me which part of the code exactly is unnecessary.
The iris class uses various client only classes directly, which results in exceptions when it is loaded at all.
That's why I added the Oculus class and added the EventBusSubscriber annotation to the Iris class, which means it is only loaded on the client.

If you think there is an alternative way to prevent this issue, please let me know

@rilakuma123
Copy link

Is it possible to do something like CaffeineMC/sodium#2773

@JulianVennen
Copy link
Author

That option does not exist on 1.20.1 (and might be neoforge exclusive).

@dima-dencep
Copy link
Collaborator

You moved the initialization to the FMLClientSetupEvent, which may be too late

@Veynam
Copy link

Veynam commented Jan 7, 2025

Please implement this feature, makes doing some things so frustrating only because of this mod

@JulianVennen
Copy link
Author

You moved the initialization to the FMLClientSetupEvent, which may be too late

Too late for what exactly? Keeping the initialization in the constructor is unfortunately not possible, as the EventBusSubscriber annotation does not create an instance of the class (unlike the Mod annotation).
I can use FMLConstructModEvent instead, which is fired "directly after mod instance construction". Would that be better?

@dima-dencep
Copy link
Collaborator

Keeping the initialization in the constructor is unfortunately not possible

Then use a static block

@JulianVennen
Copy link
Author

Unfortunately, that doesn't work as the mod list is not loaded yet: https://mclo.gs/FmmTXjq
Using the FMLConstructModEvent should result in the same timing as before

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

Successfully merging this pull request may close these issues.

Allow forge server to start up with this mod / prevent crash
4 participants