The @ModOnly annotation is as simple as the name suggests:
It only registers a ZenClass if the provided mod is loaded.

CraftTweaker Test Project ModOnly

java
Copy
@ModOnly(value = "mcp")
@ZenClass(value = "crafttweaker.tests.modOnly")
@ZenRegister
public class ModOnlyWiki {
    @ZenMethod
    public static void print() {
        CraftTweakerAPI.logInfo("print issued");
    }
}

What classes can be annotated || Additional Info

Link to what-classes-can-be-annotated--additional-info

  • You can annotate all Java Classes that also have the @ZenRegister Annotation. Technically, you can register all classes, but only there it will have an impact.
  • The Annotation requires a String value that represents the modName (isModLoaded(annotation.getValue()) has to return true of the mod is loaded)