Skip to content

Conversation

@ZZZank
Copy link
Contributor

@ZZZank ZZZank commented Nov 30, 2025

Some mods (e.g. CompatUtil in RLTweaker) will intentionally call private register method to register their event listener, even when the param type is illegal.

This PR fixed this "issue" by making EventListenerFactory generate Consumer<Event> instead of IEventListener, because the functional method in Consumer is void accept(T t);, whose param type class is Object instead of Event.


Registering event listener in this way is, in my opinion, really stupid and far from best practice, especially when you can just create a new class with legal param type, and prevent loading non-existent event classes by simply not using such class:

class OptionalEventHandler {
    public static void optionalEvent(SomeOptionalEvent event) {
        // ...
    }
}

if (modLoaded("some_mod_that_provides_optional_event")) {
    MinecraftForge.EVENT_BUS.register(OptionalEventHandler.class);
}

@Ecdcaeb
Copy link
Contributor

Ecdcaeb commented Nov 30, 2025

may check and log a warning?

@kappa-maintainer kappa-maintainer merged commit 869da5e into CleanroomMC:main Nov 30, 2025
1 check passed
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.

3 participants