|
Quilt Loader 1
|
Applied to declare that the annotated element requires specific mods to exist. More...
Public Member Functions | |
| String[] | value () |
| boolean | stripLambdas () default true |
Applied to declare that the annotated element requires specific mods to exist.
When applied to mod code this will result in quilt-loader removing that element when running without all of the specified mods.
When the annotated element is removed, bytecode associated with the element will not be removed. For example, if a field is removed, its initializer code will not, and will cause an error on execution.
If an overriding method has this annotation and its overridden method doesn't, unexpected behavior may happen. If an overridden method has this annotation while the overriding method doesn't, it is safe, but the method can be used from the overridden class only when specified mods are found.
When applied to an implemented interface (via ElementType#TYPE_USE) it will be removed when running without the specified mods. Overridden interface methods need to be annotated separately in order to be removed.
@apiNote Even is this annotation is provided by Quilt Loader, some usages of it are not recommended. In example, when you are using code from other mods thanks to their APIs using entrypoints, you should not implement their entrypoint interface on the same classes that you are using for vanilla entrypoints. Instead, you should use a separate class in a separated package, dedicated to the mod integration that you are making. And to continue this example by a great usage of this annotation, you could use it in a new package-info.java file of the current package dedicated for the mod integration, in order to trim the complete package, which will provide an additional safety layer by avoiding errors when loading and / or calling classes and elements that should not when the required mod is not present.
| boolean org.quiltmc.loader.api.Requires.stripLambdas | ( | ) |
| String[] org.quiltmc.loader.api.Requires.value | ( | ) |