Skip to content

Mixin error: Cannot resolve method in target class #1782

You must be logged in to vote

The kill() method is in the LivingEntity class so you need:
@Mixin(LivingEntity.class)

If you just want it for player entities, you can override the method using normal java rules instead of an injection

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin extends LivingEntity  {
<snip/>
    @Override
    public void kill()
    {
        super.kill(); // LivingEntity.kill()
        MinecraftClient.getInstance().player.sendMessage(new LiteralText("kill() called."), false);
    }

But this might conflict with other mods if they do the same thing.

Also, the way you have written it doesn't work properly in general.
The kill() command runs on the server where MinecraftClient won'…

Replies: 6 comments 4 replies

You must be logged in to vote
2 replies
@SirEnder125

@LlamaLad7

Answer selected by SirEnder125

You must be logged in to vote
1 reply
@SirEnder125

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
1 reply
@SirEnder125

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants