tutorial:accesswideners
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:accesswideners [2020/05/18 04:58] – [Access Wideners] grammar + spelling glitch | tutorial:accesswideners [2024/04/29 21:00] (current) – AW only for Vanilla ayutac | ||
---|---|---|---|
Line 3: | Line 3: | ||
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 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 | + | Access wideners |
+ | * Needing to access | ||
+ | * Being able to override final methods or subclass final classes. | ||
+ | * If you want to subclass a class with only (package) private constructors, | ||
+ | |||
+ | In order for access widener changes to show up in the decompiled source, run the '' | ||
+ | |||
+ | Note: Access wideners | ||
===== Requirements ===== | ===== Requirements ===== | ||
* Fabric-loader 0.8.0 or higher | * Fabric-loader 0.8.0 or higher | ||
* Loom 0.2.7 or higher | * Loom 0.2.7 or higher | ||
- | |||
===== File format ===== | ===== File format ===== | ||
- | A specific file format is used to define the access changes included in your mod. To aid IDE' | + | A specific file format is used to define the access changes included in your mod. To aid IDE's you should use the '' |
- | The file must start with the following header, `namespace` should | + | The file must start with the following header. '' |
<code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
- | accessWidener v1 < | + | accessWidener |
</ | </ | ||
+ | |||
+ | **Once again, the namespace should be '' | ||
Access widener files can have blank lines and comments starting with # | Access widener files can have blank lines and comments starting with # | ||
<code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
- | # Comments like this are supported, as well at the end of the line | + | # Comments like this are supported, as well as at the end of the line |
</ | </ | ||
- | Any whitespace can be used to sperate | + | Any whitespace can be used to separate |
Class names are separated with a / and not . | Class names are separated with a / and not . | ||
+ | |||
+ | For inner classes, you should use '' | ||
== Classes == | == Classes == | ||
Class access can be changed by specifying the access and the class name as named the mappings namespace defined in the header. | Class access can be changed by specifying the access and the class name as named the mappings namespace defined in the header. | ||
+ | |||
<code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
Line 41: | Line 52: | ||
== Methods == | == Methods == | ||
- | Method access can be changed by specifying the access, class name, method name and method | + | Method access can be changed by specifying the access, class name, method name and method |
<code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
Line 48: | Line 59: | ||
- access can be // | - access can be // | ||
- | - classname | + | - className |
- methodName is the method name | - methodName is the method name | ||
- | - methodDesc is the method | + | - methodDesc is the method |
== Fields == | == Fields == | ||
- | Field access can be changed by specifying the access, class name, field name and field descriptior | + | Field access can be changed by specifying the access, class name, field name and field descriptor |
<code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
Line 63: | Line 74: | ||
- className is the owner class | - className is the owner class | ||
- fieldName is the field name | - fieldName is the field name | ||
- | - fieldDesc is the field descriptior | + | - fieldDesc is the field descriptor |
===== Access Changes ===== | ===== Access Changes ===== | ||
Line 91: | Line 102: | ||
* Fields have final removed | * Fields have final removed | ||
+ | |||
+ | If you want to make a private final field both accessible //and// mutable, you need to use two directives, one for each change. | ||
===== Specifying file location ===== | ===== Specifying file location ===== | ||
- | 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. | + | 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. (Replace " |
+ | |||
+ | Loom 0.9 or higher: | ||
+ | |||
+ | <code groovy [enable_line_numbers=" | ||
+ | loom { | ||
+ | accessWidenerPath = file(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Loom 0.8 or lower: | ||
<code groovy [enable_line_numbers=" | <code groovy [enable_line_numbers=" | ||
- | minecraft | + | loom { |
accessWidener = file(" | accessWidener = file(" | ||
} | } | ||
</ | </ | ||
+ | |||
+ | fabric.mod.json: | ||
<code json [enable_line_numbers=" | <code json [enable_line_numbers=" | ||
... | ... | ||
- | " | + | " |
... | ... | ||
</ | </ | ||
+ | |||
+ | ===== Validating the file ===== | ||
+ | By default, accesswidener entries that don't exist are ignored. | ||
+ | On recent versions of Loom, you can run '' | ||
+ | |||
+ | The error messages can be a little cryptic. For example, if you make a mistake in specifying a field, the error doesn' | ||
+ | |||
+ | ===== V2 changes ===== | ||
+ | |||
+ | With the v2 version, the '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | They differ from their regular, non-prefixed variants in that they also apply to mods that depend on this one. | ||
+ | |||
+ | |||
+ |
tutorial/accesswideners.txt · Last modified: 2024/04/29 21:00 by ayutac