tutorial:accesswidening
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| tutorial:accesswidening [2025/11/21 13:26] – ↷ Page name changed from tutorial:accesswideners to tutorial:accesswidening gauntrecluse | tutorial:accesswidening [2025/11/23 23:40] (current) – The big class tweaker rename earthcomputer | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Access Widening ====== | ====== Access Widening ====== | ||
| - | Access widening provides a way to loosen the access limits of classes, methods or fields. | + | Access widening provides a way to loosen the access limits of classes, methods or fields. |
| - | Access | + | Access |
| * Needing to access a (package) private class, especially for the purpose of shadowing or accessing a field or method in a mixin. | * Needing to access a (package) private class, especially for the purpose of shadowing or accessing a field or method in a mixin. | ||
| * Being able to override final methods or subclass final classes. | * Being able to override final methods or subclass final classes. | ||
| * If you want to subclass a class with only (package) private constructors, | * 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 '' | + | Access widening is a type of //class tweaking//, and is defined |
| - | Note: Unlike accessor mixins, | + | As with other types of class tweaking, in order for access widening changes to show up in the decompiled source, run the '' |
| + | |||
| + | Note: Unlike accessor mixins, | ||
| - | ===== Requirements ===== | ||
| - | * Fabric-loader 0.8.0 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 IDEs you should use the '' |
| - | The file must start with the following header. '' | + | The file must start with the following header. '' |
| <code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
| - | accessWidener v2 < | + | classTweaker v1 < |
| </ | </ | ||
| **Once again, the namespace should be '' | **Once again, the namespace should be '' | ||
| - | Access widener | + | Class tweaker |
| <code [enable_line_numbers=" | <code [enable_line_numbers=" | ||
| Line 33: | Line 32: | ||
| </ | </ | ||
| - | Any whitespace can be used to separate in the access widener | + | Any whitespace can be used to separate in the class tweaker |
| Class names are separated with a / and not . | Class names are separated with a / and not . | ||
| Line 107: | Line 106: | ||
| ===== 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. (Replace " | + | The access widener file location must be specified in your '' |
| - | Loom 0.9 or higher: | + | '' |
| <code groovy [enable_line_numbers=" | <code groovy [enable_line_numbers=" | ||
| Line 117: | Line 116: | ||
| </ | </ | ||
| - | Loom 0.8 or lower: | + | '' |
| - | + | ||
| - | <code groovy [enable_line_numbers=" | + | |
| - | loom { | + | |
| - | accessWidener = file(" | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | fabric.mod.json: | + | |
| <code json [enable_line_numbers=" | <code json [enable_line_numbers=" | ||
| Line 134: | Line 125: | ||
| ... | ... | ||
| </ | </ | ||
| + | |||
| + | Note that for backwards compatibility reasons, the class tweaker is still referred to as an " | ||
| ===== Validating the file ===== | ===== Validating the file ===== | ||
| - | By default, | + | By default, |
| - | On recent versions of Loom, you can run '' | + | You can run the '' |
| - | The error messages can be a little cryptic. For example, if you make a mistake in specifying a field, the error doesn' | + | The error messages can be a little cryptic. For example, if you make a mistake in specifying a field, the error doesn' |
| - | ===== V2 changes | + | ===== Transitive class tweakers |
| - | With the v2 version, the '' | + | On all access widener directives, the '' |
| * '' | * '' | ||
| Line 149: | Line 142: | ||
| * '' | * '' | ||
| - | They differ from their regular, non-prefixed variants in that they also apply to mods that depend on this one. | + | They differ from their regular, non-prefixed variants in that they also apply to mods that depend on this one. This is useful for library mods that want to expose their class tweaker changes. |
tutorial/accesswidening.txt · Last modified: 2025/11/23 23:40 by earthcomputer