User Tools

Site Tools


tutorial:accesswideners

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:accesswideners [2022/07/12 10:27] – Add AW validation, stop suggesting mixin as an alternative technici4ntutorial:accesswideners [2024/04/29 21:00] (current) – AW only for Vanilla ayutac
Line 8: Line 8:
     * If you want to subclass a class with only (package) private constructors, wideners are a good choice.     * If you want to subclass a class with only (package) private constructors, wideners are a good choice.
  
-In order for access widener changes to show up in the decompiled source, run the ''genSources'' gradle task.+In order for access widener changes to show up in the decompiled source, run the ''genSources'' gradle task and then reload the gradle project in your IDE. 
 + 
 +Note: Access wideners do not work for source of mods.
  
 ===== Requirements ===== ===== Requirements =====
Line 17: Line 19:
 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. 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 usually always be ''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.+The file must start with the following header''namespace'' should usually always be set to the word ''named'', and not your project namespace. Loom will remap the access widener file for you into ''intermediary'' along with your mod.
  
 <code [enable_line_numbers="true"]> <code [enable_line_numbers="true"]>
-accessWidener v1 <namespace>+accessWidener v2 <namespace>
 </code> </code>
  
Line 100: 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 "modid" in the example with your own mod ID.)
  
 Loom 0.9 or higher: Loom 0.9 or higher:
Line 134: Line 138:
 By default, accesswidener entries that don't exist are ignored. By default, accesswidener entries that don't exist are ignored.
 On recent versions of Loom, you can run ''gradlew validateAccessWidener'' to check that all the classes, fields and methods specified in the accesswidener file exist. On recent versions of Loom, you can run ''gradlew validateAccessWidener'' to check that all the classes, fields and methods specified in the accesswidener file exist.
 +
 +The error messages can be a little cryptic. For example, if you make a mistake in specifying a field, the error doesn't say whether the name or the type is the problem For example, if it says it cannot find the field "''fooI''", it could mean there is no field named ''foo'', or that it exists but isn't an ''int'' (''I'').
 +
 +===== V2 changes =====
 +
 +With the v2 version, the ''transitive-*'' prefixed keywords have been added:
 +
 +  * ''transitive-accessible''
 +  * ''transitive-extendable''
 +  * ''transitive-mutable''
 +
 +They differ from their regular, non-prefixed variants in that they also apply to mods that depend on this one.
 +
 +
 +
tutorial/accesswideners.1657621650.txt.gz · Last modified: 2022/07/12 10:27 by technici4n