tutorial:accesswidening
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:accesswidening [2025/11/23 23:40] – The big class tweaker rename earthcomputer | tutorial:accesswidening [2026/01/09 15:07] (current) – Make accessor mentions link to accessor mixins page gauntrecluse | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Access widening provides a way to loosen the access limits of classes, methods or fields. This includes making them public, or making them extendable (subclassable). | Access widening provides a way to loosen the access limits of classes, methods or fields. This includes making them public, or making them extendable (subclassable). | ||
| - | Access widening may be used instead of accessor mixins, and there are currently 2 cases where the functionality provided by mixin is not sufficient: | + | Access widening may be used instead of [[tutorial: |
| * 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, | ||
| - | Access widening is a type of //class tweaking//, and is defined in the class tweaker file. In previous Fabric versions, the class tweaker was known as the " | + | Access widening is a type of //class tweaking//, and is defined in the class tweaker file. In previous Fabric versions |
| As with other types of class tweaking, in order for access widening changes to show up in the decompiled source, run the '' | 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, class tweaking only works on Minecraft code, and not on other mods. | + | Note: Unlike |
| ===== File format ===== | ===== File format ===== | ||
| Line 18: | Line 18: | ||
| A specific file format is used to define the access changes included in your mod. To aid IDEs you should use the '' | 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=" | ||
| Line 112: | Line 112: | ||
| <code groovy [enable_line_numbers=" | <code groovy [enable_line_numbers=" | ||
| loom { | loom { | ||
| - | accessWidenerPath = file(" | + | accessWidenerPath = file(" |
| } | } | ||
| </ | </ | ||
| Line 121: | Line 121: | ||
| ... | ... | ||
| - | " | + | " |
| ... | ... | ||
tutorial/accesswidening.1763941213.txt.gz · Last modified: 2025/11/23 23:40 by earthcomputer