-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conditional mods & event bus subscribers #212
base: main
Are you sure you want to change the base?
Conditional mods & event bus subscribers #212
Conversation
|
Can you use @dependency without wrapping it in @ChainDependency? I'm quite sure most use-cases would be just depending on one single modid. |
Uh oh I accidentally mentioned someone |
I don't like how this is modeled. |
Looking at the beginning of the impl, it seems you can use |
Would a model like this be preferable? @DependsOn(value = "neoforge", condition = Condition.ALL_PRESENT, operator = Operator.AND)
@DependsOn(value = {"othermod", "othermod2"}, condition = Condition.AT_LEAST_ONE_PRESENT, operator = Operator.OR)
@DependsOn("othermod3")
@Mod("testmod")
public class TestMod {
public TestMod() {
//called when neoforge and one of othermod or othermod2 are present or when othermod3 is present
}
} The least verbose one dependency would be |
Why do you need such a complex expression language beyond simple AND/OR which could be expressed through a repeatable annotation / value array attribute? |
I think that OR conditions are quite suspicious if the goal is to avoid crashes because of missing classes. |
The new model is comprised of AND/ORs and their respective negations @DependsOn("neoforge")
@DependsOn(value = { "othermod", "othermod2" }, condition = DependsOn.Operation.OR)
@DependsOn("othermod3") @DependsOn.List({
@DependsOn("neoforge"),
@DependsOn(value = { "othermod", "othermod2" }, condition = DependsOn.Operation.OR),
@DependsOn("othermod3")
}) Both of the preceding annotations will behave the same Refer to the |
The main goal of checking for dependencies in the annotation like this, is to prevent accidentally loading code that references nonexisting classes. If you add NOT or OR dependencies, that flies out of the window, and you might as well just add the following code instead of writing convoluted annotations: if (ModList.get().isModLoaded("a") && !ModList.get().isModLoaded("b")) {
bus.register(AButNotBEventHandler.class);
} |
Removed ORs and NOTs, |
Conditional class loading described in #201