Jump to content

[1.19.2] [Solved] player.startFallFlying() is not working.


Recommended Posts

Posted (edited)

Hello,

I'm having an issue with getting players to use elytra flight. They do not have any elytra armour on their chest plate but rather the elytra is rendered on the player.

What I've got so far seems to make the server 'fight' with itself making the person with the elytra begin flying but immediately go back to non-flight. 

I'm checking if the player is off the ground and such client and server side using packets.

Client code:

        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public static void onKeyInput(InputEvent.Key event) {
            if (Minecraft.getInstance().options.keyJump.consumeClick()) {
                Player player = Minecraft.getInstance().player;

                if (!player.isOnGround() && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION)) {
                    NetworkManager.sendToServer(new ElytraAttemptFlyPacket());
                }
            }
        }
    }



Server code:

public class ElytraAttemptFlyPacket {

    public ElytraAttemptFlyPacket(FriendlyByteBuf buf) {
    }

    public ElytraAttemptFlyPacket() {
    }

    public void toBytes(FriendlyByteBuf buf) {
    }

    public boolean handle(Supplier<NetworkEvent.Context> supplier) {
        NetworkEvent.Context context = supplier.get();
        context.enqueueWork(() -> {
            //Server
            ServerPlayer player = context.getSender();

            if (!player.isOnGround() && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION)) {
                player.startFallFlying();
            }
        });
        return true;
    }
}



As I said before it kind of works but it looks like the server is fighting with itself putting the player in elytra mode and normal mode.

Any suggestions would be appreciated!!

Edited by HixlePod
Issue was solved using the Caelus API.
  • HixlePod changed the title to [1.19.2] player.startFallFlying() is not working.
  • HixlePod changed the title to [1.19.2] [Solved] player.startFallFlying() is not working.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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