tutorial:mixin_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:mixin_examples [2020/09/14 05:28] – minor improvement siglong | tutorial:mixin_examples [2021/08/07 07:08] – Add "modifying a constant" example fracturedcode | ||
---|---|---|---|
Line 64: | Line 64: | ||
</ | </ | ||
- | ===== Injecting into before method call ===== | + | ===== Injecting into the point before |
Mixin: | Mixin: | ||
<code java> | <code java> | ||
Line 84: | Line 84: | ||
</ | </ | ||
- | ===== Injecting into after method call ===== | + | ===== Injecting into the point after a method call ===== |
Mixin: | Mixin: | ||
<code java> | <code java> | ||
Line 111: | Line 111: | ||
at = @At( | at = @At( | ||
value = " | value = " | ||
- | target = " | + | target = " |
- | slice = @Slice( | + | |
- | from = @At(value = " | + | slice = @Slice( |
- | to = @At(value = " | + | from = @At(value = " |
+ | to = @At(value = " | ||
+ | | ||
+ | ) | ||
private void injected(CallbackInfo ci) { | private void injected(CallbackInfo ci) { | ||
doSomething5(); | doSomething5(); | ||
Line 356: | Line 359: | ||
+ | + | ||
double d2 = doSomething4(); | double d2 = doSomething4(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Modifying a constant ===== | ||
+ | Mixin: | ||
+ | <code java> | ||
+ | @ModifyConstant(method = " | ||
+ | private int injected(int value) { | ||
+ | return ++value; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Result: | ||
+ | <code diff> | ||
+ | public void foo() { | ||
+ | - for (int i = 0; i < 4; i++) { | ||
+ | + for (int i = 0; i < 5; i++) { | ||
+ | doSomething(i); | ||
+ | } | ||
} | } | ||
</ | </ |
tutorial/mixin_examples.txt · Last modified: 2024/01/13 15:02 by arkosammy12