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
Next revisionBoth sides next revision
tutorial:accesswideners [2020/06/22 14:13] – Clarify the circumstances where an access widener should and should not be used earthcomputertutorial:accesswideners [2021/08/07 22:13] modmuss50
Line 5: Line 5:
 Access wideners should **only** be used where mixin does not currently provide a means to do so. Access wideners should **only** be used where mixin does not currently provide a means to do so.
 There are currently only 2 cases where mixins are not sufficient: There are currently only 2 cases where mixins are not sufficient:
-  * Needing to access a 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.
 +    * Before you consider overriding final methods, try mixin injecting in final methods first!
 +    * 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.
  
 ===== 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 =====
  
Line 21: Line 24:
 accessWidener v1 <namespace> accessWidener v1 <namespace>
 </code> </code>
 +
 +**Once again, the namespace should match ''named'' when using yarn names and ''intermediary'' when using intermediary names.**
  
 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="true"]> <code [enable_line_numbers="true"]>
-# 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
 </code> </code>
  
Line 101: Line 106:
  
 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.
 +
 +Loom 0.9 or higher:
  
 <code groovy [enable_line_numbers="true"]> <code groovy [enable_line_numbers="true"]>
-minecraft +loom 
- accessWidener "src/main/resources/modid.accesswidener"+ accessWidenerPath = file("src/main/resources/modid.accesswidener")
 } }
 </code> </code>
 +
 +Loom 0.8 or lower:
 +
 +<code groovy [enable_line_numbers="true"]>
 +loom {
 + accessWidener = file("src/main/resources/modid.accesswidener")
 +}
 +</code>
 +
 +fabric.mod.json:
  
 <code json [enable_line_numbers="true"]> <code json [enable_line_numbers="true"]>
 ... ...
  
-"accessWidener" : "modid.accesswidener","+"accessWidener" : "modid.accesswidener",
  
 ... ...
 </code> </code>
tutorial/accesswideners.txt · Last modified: 2024/06/09 05:33 by haykam