Setup
Basics
- Conventions and Terminology
- Registries
- Development Tools
Access wideners provide a way to loosen the access limits of classes, methods or fields. Access wideners are similar to the commonly known Access Transformers.
Access wideners should only be used where mixin does not currently provide a means to do so. There are currently only 2 cases where mixins are not sufficient:
In order for access widener changes to show up in the decompiled source, run the genSources
gradle task.
A specific file format is used to define the access changes included in your mod. To aid IDE's you should use the .accesswidener
file extension.
The file must start with the following header, namespace
should match the mappings namespace of your mod's source code, this is usually named
. Loom will remap the access widener file for you into intermediary
along with your mod. If you use a custom RemapJarTask
, set remapAccessWidener
property on it to true
to ensure this happens.
accessWidener v1 <namespace>
Access widener files can have blank lines and comments starting with #
# Comments like this are supported, as well as at the end of the line
Any whitespace can be used to separate in the access widener file, tab is recommended.
Class names are separated with a / and not .
For inner classes, you should use $
instead of /
Class access can be changed by specifying the access and the class name as named the mappings namespace defined in the header.
<access> class <className>
Method access can be changed by specifying the access, class name, method name and method descriptor as named the mappings namespace defined in the header.
<access> method <className> <methodName> <methodDesc>
Field access can be changed by specifying the access, class name, field name and field descriptor as named the mappings namespace defined in the header.
<access> field <className> <fieldName> <fieldDesc>
Extendable should be used where you want to extend a class or override a method.
Making a method extendable also makes the class extendable.
Accessible should be used when you want to access a class, field or method from another class.
Making a method or field accessible also makes the class accessible.
Mutable should be used when you want to mutate a final field
The access widener file location must be specified in your build.gradle and in your fabric.mod.json file. It should be stored in the resources as it needs to be included in the exported jar file.
loom { accessWidener "src/main/resources/modid.accesswidener" }
... "accessWidener" : "modid.accesswidener", ...