I need to provide an explanation for this:
In the case of having classes Foo and Bar extends Foo, I have times where I want to soft override Foo#baz() when I already have MixinFoo and MixinBar.
In code:
public class Foo {
public void baz() {
// something
}
}
public class Bar extends Foo {
public void fooBar() {
// something else
}
}
@Mixin(Foo.class)
public class MixinFoo {
@Shadow public void baz() {
// shadowed! Doesn't actually do anything
}
}
@Mixin(Bar.class)
public class MixinBar extends MixinFoo {
@Override
public void baz() {
// actually do something different?
}
}
I've come across wanting this functionality, since Generate > Overwrite methods... is available and Generate > Shadow members... is available. In this case, it'd be easier to do something akin to:
Generate > Override target superclass members (name is whatever) where it first generates the shadowed member method as required (for most cases, should just dummy implement with defaults), and then provide the *exact same method from an Overwrite but as a simple @Override in the subclass mixin.
Examples from Sponge include:
MixinEntityLivingBase
https://github.com/SpongePowered/SpongeCommon/blob/06f890888049ff5fa501c84780076a6e0c8346e9/src/main/java/org/spongepowered/common/mixin/core/entity/MixinEntityLivingBase.java#L205-L207
MixinEntityArmorStand
https://github.com/SpongePowered/SpongeCommon/blob/06f890888049ff5fa501c84780076a6e0c8346e9/src/main/java/org/spongepowered/common/mixin/core/entity/item/MixinEntityArmorStand.java#L216
Of course, this is more of a convenience as more and more of the plugin I get to use to do some fancy things with mixins.
I need to provide an explanation for this:
In the case of having classes
FooandBar extends Foo, I have times where I want to soft overrideFoo#baz()when I already haveMixinFooandMixinBar.In code:
I've come across wanting this functionality, since
Generate > Overwrite methods...is available andGenerate > Shadow members...is available. In this case, it'd be easier to do something akin to:Generate > Override target superclass members (name is whatever)where it first generates the shadowed member method as required (for most cases, should just dummy implement with defaults), and then provide the *exact same method from anOverwritebut as a simple@Overridein the subclass mixin.Examples from Sponge include:
MixinEntityLivingBasehttps://github.com/SpongePowered/SpongeCommon/blob/06f890888049ff5fa501c84780076a6e0c8346e9/src/main/java/org/spongepowered/common/mixin/core/entity/MixinEntityLivingBase.java#L205-L207
MixinEntityArmorStandhttps://github.com/SpongePowered/SpongeCommon/blob/06f890888049ff5fa501c84780076a6e0c8346e9/src/main/java/org/spongepowered/common/mixin/core/entity/item/MixinEntityArmorStand.java#L216
Of course, this is more of a convenience as more and more of the plugin I get to use to do some fancy things with mixins.