LlamaLad7 / MixinExtras

Companion library to SpongePowered Mixin with many custom injectors for a more expressive experience.
MIT License
309 stars 17 forks source link

[Suggestion] `@This` annotation #80

Closed dhyces closed 6 months ago

dhyces commented 6 months ago

Wanted to pick people's minds about this kind of annotation:

@Inject(method = "hurt", at = @At("HEAD"))
private void myMixin(int arg, CallbackInfo ci, @This LivingEntity thiz) {
    if (thiz instanceof Player player) {
        // do something
    } else if (thiz instanceof Shulker shulker) {
        // do something else
    }
}

Very simple example, it's just for convenience, makes things a little more straightforward

LlamaLad7 commented 6 months ago

You already have this directly, together with appropriate shadowing, extending of the target's parent or casting.

dhyces commented 6 months ago

That was closed quickly :p, but I completely understand