tutorial:mixin_examples
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:mixin_examples [2025/10/12 09:21] – Mark page as having a planned rewrite gauntrecluse | tutorial:mixin_examples [2026/05/16 08:25] (current) – Clarify that using shift by is discouraged. earthcomputer | ||
|---|---|---|---|
| Line 153: | Line 153: | ||
| ===== Injecting into the point with shift amount ===== | ===== Injecting into the point with shift amount ===== | ||
| + | :!: Using a shift amount is heavily discouraged, | ||
| + | |||
| Mixin: | Mixin: | ||
| <code java> | <code java> | ||
| Line 349: | Line 351: | ||
| Mixin: | Mixin: | ||
| <code java> | <code java> | ||
| - | @Inject(method = "foo()I;", at = @At(" | + | @ModifyReturnValue(method = " |
| - | private | + | private |
| - | | + | |
| } | } | ||
| </ | </ | ||
| Line 357: | Line 359: | ||
| Result: | Result: | ||
| <code diff> | <code diff> | ||
| - | | + | public int foo() { |
| doSomething1(); | doSomething1(); | ||
| doSomething2(); | doSomething2(); | ||
| - | - | ||
| - | + int i = doSomething3() + 7; | + | + return this.exampleModifyReturnValue(doSomething3() + 7); |
| - | + | + | } |
| - | + | + | |
| - | + if (cir.isCancelled()) return cir.getReturnValue(); | + | |
| - | + | + | |
| - | | + | |
| </ | </ | ||
tutorial/mixin_examples.1760260864.txt.gz · Last modified: 2025/10/12 09:21 by gauntrecluse