drafts:mixin_override
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| drafts:mixin_override [2025/11/02 15:42] – created gauntrecluse | drafts:mixin_override [2025/11/03 14:52] (current) – gauntrecluse | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| :!: //This is a draft! Feedback is appreciated, | :!: //This is a draft! Feedback is appreciated, | ||
| + | |||
| + | //TODO List: Example of how a direct injection attempt would fail; Note about how submixin patterns cannot contain interfaces// | ||
| ====== Creating an Override in a target class (DRAFT) ====== | ====== Creating an Override in a target class (DRAFT) ====== | ||
| Line 31: | Line 33: | ||
| - | ===== Compatible | + | ===== The Solutions ===== |
| ==== Injecting an instanceof check in the super ==== | ==== Injecting an instanceof check in the super ==== | ||
| We can inject a check within the method we wish to functionally override, which will execute our custom operations if the '' | We can inject a check within the method we wish to functionally override, which will execute our custom operations if the '' | ||
| Line 39: | Line 41: | ||
| @WrapMethod(method = " | @WrapMethod(method = " | ||
| private boolean doSomethingForCopperGolem(ServerWorld world, DamageSource source, float amount, Operation< | private boolean doSomethingForCopperGolem(ServerWorld world, DamageSource source, float amount, Operation< | ||
| - | if ((Object) this instanceof CopperGolemEntity) { | + | if ((Object) this instanceof CopperGolemEntity) { // We have to cast to Object first to satisfy the compiler |
| ExampleMod.doSomething(); | ExampleMod.doSomething(); | ||
| } | } | ||
drafts/mixin_override.1762098123.txt.gz · Last modified: 2025/11/02 15:42 by gauntrecluse