Jump to content

[Solved] I need help with a Mixin Class to inject into a Method

Jonas Handtke

Recommended Posts

EDIT: I found the Solution how to fix it by myself.

I'm trying to make a Event that is fired if a Player is swimming.

Here is the Event Class:

public class PlayerSwimEvent extends PlayerEvent {

    public PlayerSwimEvent(Player player) {

Here is the Hooks (similar to ForgeHooks Class) that has Methods for the Events:

public class EventHooks {
    public static void onPlayerSwim(Player player) {
        MinecraftForge.EVENT_BUS.post(new PlayerSwimEvent(player));

And here is the Mixin Class:

@Mixin(value = Player.class)
public class MixinPlayerSwimEvent {
    @Inject(method = "isSwimming", at = @At("HEAD"))
    public boolean isSwimming(CallbackInfoReturnable<Boolean> cir) {
        Player player = null;
        if (!player.getAbilities().flying && !player.isSpectator()) {
        return cir.getReturnValue();

My Issue is now that I don't get it to work because of the missing Parameter Player. Can someone help with this?

Edited by Jonas Handtke
Found the Solution by myself
Link to comment
Share on other sites

  • Jonas Handtke changed the title to [Solved] I need help with a Mixin Class to inject into a Method

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.