tutorial:mixin_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:mixin_examples [2023/12/18 02:18] – [Capturing local values] solidblock | tutorial:mixin_examples [2023/12/18 02:24] – [Capturing locals from multiple locals of a type] solidblock | ||
---|---|---|---|
Line 296: | Line 296: | ||
</ | </ | ||
- | ==== Capturing | + | ==== Capturing |
Mixin: | Mixin: | ||
<code java> | <code java> | ||
Line 314: | Line 314: | ||
doSomething(); | doSomething(); | ||
+ | + | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Modifying locals ===== | ||
+ | This requires MixinExtras. | ||
+ | |||
+ | Mixin: | ||
+ | <code java> | ||
+ | @Inject(method = " | ||
+ | private static void injected(CallbackInfo ci, @Local LocalRef< | ||
+ | localRef.set(localRef.get() + " - modified" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Result: | ||
+ | <code diff> | ||
+ | public void foo() { | ||
+ | String s = " | ||
+ | doSomething(); | ||
+ | + s = s + " - modified"; | ||
+ | doSomething2(s); | ||
} | } | ||
</ | </ |
tutorial/mixin_examples.txt · Last modified: 2024/01/13 15:02 by arkosammy12