User Tools

Site Tools


tutorial:mixin_accessors

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:mixin_accessors [2025/08/07 07:44] – Fix formatting earthcomputertutorial:mixin_accessors [2025/08/07 07:48] (current) – Add note about mutable to static accessors too, and note about javac inlining fields. earthcomputer
Line 35: Line 35:
 </code> </code>
  
-When the field is final and you need to set it, use ''@Mutable'' as well.+When the field is final and you need to set it, use ''@Mutable'' as well. Note that this may not work as expected if the field is set to a constant literal value in its initializer, such as ''42'' or ''"Hello World"''. This is because ''javac'' inlines constant fields.
  
 ===== Accessor for static fields ===== ===== Accessor for static fields =====
Line 73: Line 73:
 VanillaLayeredBiomeSourceAccessor.setBiomes(biomes); VanillaLayeredBiomeSourceAccessor.setBiomes(biomes);
 </code> </code>
 +
 +When the field is final and you need to set it, use ''@Mutable'' as well. Note that this may not work as expected if the field is set to a constant literal value in its initializer, such as ''42'' or ''"Hello World"''. This is because ''javac'' inlines constant fields.
  
 ===== Invoker ===== ===== Invoker =====
tutorial/mixin_accessors.txt · Last modified: 2025/08/07 07:48 by earthcomputer