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
fix(annotations): prevent the OnlyIn annotation being used on EventBusSubscriber and Mod annotated classes #9891
base: 1.20.x
Are you sure you want to change the base?
Conversation
…sSubscriber and Mod annotated classes
Is there a real need for this? Have you seen many mods do this? |
javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/AutomaticEventSubscriber.java
Outdated
Show resolved
Hide resolved
javafmllanguage/src/main/java/net/minecraftforge/fml/javafmlmod/AutomaticEventSubscriber.java
Outdated
Show resolved
Hide resolved
if (!FMLEnvironment.production && hasOnlyInWithModAnnotation(classNode.visibleAnnotations)) | ||
{ | ||
LOGGER.error(DISTXFORM, "Attempted to load class {} with @Mod and @OnlyIn/@OnlyIns annotations", classNode.name); | ||
throw new RuntimeException("Attempted to load class "+ classNode.name + " with @Mod and @OnlyIn/@OnlyIns annotations you should instead use the side setting in the mods.toml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new RuntimeException("Attempted to load class "+ classNode.name + " with @Mod and @OnlyIn/@OnlyIns annotations you should instead use the side setting in the mods.toml"); | |
throw new RuntimeException("Found @OnlyIn on @Mod class "+ classNode.name + " - this is not allowed as it causes crashes. Remove the OnlyIn and consider setting clientSideOnly=true in the root of your mods.toml instead"); |
fmlloader/src/main/java/net/minecraftforge/fml/loading/RuntimeDistCleaner.java
Show resolved
Hide resolved
I added it to the wishlist because I noticed some devs do this thinking it fixes crashing servers, when in reality it just gives a different error at best. It's not common, but the less mods using OnlyIn incorrectly, the better for everyone.
Thanks, I'll merge once my requested changes are implemented. As for the verbosity, half of it seems to be a cleanup of the RuntimeDistCleaner to use less streams |
…d/AutomaticEventSubscriber.java Co-authored-by: Paint_Ninja <PaintNinja@users.noreply.github.com>
Adds checks to prevent the OnlyIn annotation being used in erroneous places such as classes annotated with the
@Mod
, or@EventBusSubscriber
as outlined here