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/21 13:26] – ↷ Page name changed from tutorial:accesswideners to tutorial:accesswidening gauntrecluse | tutorial:accesswidening [2026/03/24 17:08] (current) – Redirect to the new Docs page gauntrecluse | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~REDIRECT> | ||
| + | |||
| ====== 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 | + | Access widening is a type of //class tweaking//, and is defined in the class tweaker file. In previous Fabric versions (before Loom 1.13), the class tweaker was known as the " |
| + | |||
| + | As with other types of class tweaking, in order for access | ||
| - | Note: Unlike accessor mixins, | + | Note: Unlike |
| - | ===== 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 34: | ||
| </ | </ | ||
| - | 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 108: | ||
| ===== 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=" | ||
| loom { | loom { | ||
| - | accessWidenerPath = file(" | + | accessWidenerPath = file(" |
| } | } | ||
| </ | </ | ||
| - | 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=" | ||
| ... | ... | ||
| - | " | + | " |
| ... | ... | ||
| </ | </ | ||
| + | |||
| + | 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 144: | ||
| * '' | * '' | ||
| - | 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.1763731562.txt.gz · Last modified: 2025/11/21 13:26 by gauntrecluse