User Tools

Site Tools


tutorial:accesswidening

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:accesswidening [2025/12/02 02:07] – fix: change the .accesswidener extension to .classtweaker cootshktutorial: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:mixin_accessors|accessor mixins]], and there are currently 2 cases where the functionality provided by mixin is not sufficient:
   * 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, wideners are a good choice.     * If you want to subclass a class with only (package) private constructors, wideners are a good choice.
  
-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 widener" (as it had no other functionality).+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 "access widener" (as it had no other functionality).
  
 As with other types of class tweaking, in order for access widening changes to show up in the decompiled source, run the ''genSources'' gradle task and then reload the gradle project in your IDE. As with other types of class tweaking, in order for access widening changes to show up in the decompiled source, run the ''genSources'' gradle task and then reload the gradle project in your IDE.
  
-Note: Unlike accessor mixins, class tweaking only works on Minecraft code, and not on other mods.+Note: Unlike [[tutorial:mixin_accessors|accessor mixins]], class tweaking only works on Minecraft code, and not on other mods.
  
 ===== 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 ''.classtweaker'' file extension. A specific file format is used to define the access changes included in your mod. To aid IDEs you should use the ''.classtweaker'' file extension.
  
-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 class tweaker file for you into ''intermediary'' along with your mod. In unobfuscated versions (upcoming, 1.21.12+), the namespace will be ''official'', and the class tweaker will not be remapped.+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 class tweaker file for you into ''intermediary'' along with your mod. In unobfuscated versions (upcoming, 26.1+), the namespace will be ''official'', and the class tweaker will not be remapped.
  
 <code [enable_line_numbers="true"]> <code [enable_line_numbers="true"]>
tutorial/accesswidening.1764641268.txt.gz · Last modified: 2025/12/02 02:07 by cootshk