Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.
On 1/29/2023 at 1:59 PM, HixlePod said:

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.

There was a PR on adding a custom elytra item. Unless you're doing this without any items whatsoever, I would suggest using the system Forge already has hooked for you.

  • Author

I am using the Caelus API to handle my elytra flight, so far it seems to have solved my issue. Thank you for your help though!!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.