Skip to content

Conversation

@hedgehog1029
Copy link

@hedgehog1029 hedgehog1029 commented Dec 3, 2025

Fixes #201, alternative to #212

This PR adds the ability to specify entrypoints that will only be loaded if the specified mod ID(s) are present:

@Mod(value = "mymod", depends = {"othermod"})
public class MyEntrypoint {
    public MyEntrypoint(ModContainer mod) {
        // for example, now you can depend on OtherModExtension.class safely
        mod.registerExtensionPoint(OtherModExtension.class, () -> new MyOtherModCompatibility());
    }
}

This is implemented by checking against the LoadingModList - entrypoints with depends missing from the loading list are filtered out early.
We enforce in validate that any dependencies specified in the annotation are also specified in the mods.toml - this ensures the mods are loaded in the correct order. No longer enforced, leave it up to developers to choose.

Please let me know if this is a sane approach! Otherwise I suppose I'll have to rethink and move the filtering to a later step.

Unit tests have been added to validate the new behaviour.

@neoforged-automation neoforged-automation bot added the enhancement New feature or request label Dec 3, 2025
@neoforged-pr-publishing
Copy link

  • Publish PR to GitHub Packages

@neoforged-compatibility-checks
Copy link

neoforged-compatibility-checks bot commented Dec 3, 2025

@hedgehog1029, this PR introduces breaking changes.
Fortunately, this project is currently accepting breaking changes, but if they are not intentional, please revert them.
Last checked commit: 3a8905b97c3421ccfdc0e195a6c3d6276c20b335.

loader (:loader)

  • net/neoforged/fml/common/Mod
    • depends()[Ljava/lang/String;: ❗ Method was made abstract

@vfyjxf
Copy link

vfyjxf commented Dec 5, 2025

why not add a new mod depency type to mods.toml to impl this feature?
Adding new members to Mod annotation look weird, fml currently puts all the metadata in toml

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotation for loading class if mod is present

3 participants