NeoForge icon indicating copy to clipboard operation
NeoForge copied to clipboard

Flight Attribute doesn't properly sync to client `flying`

Open Soaryn opened this issue 1 year ago • 1 comments

Minecraft Version: 1.21.x

NeoForge Version: 21.1.6

Steps to Reproduce:

  1. Have some form of flight being provided via the attribute that is toggleable.
  2. Upon starting to fly, toggle the attribute off.
  3. This should result in the attribute turning off, on the server and flying and mayFly; however, because the client seems to get mayFly correctly turned off, flying is still followed through to be true. This causes the player to have flight, but also not be able to disengage said flight until they land potentially killing their character.

An example mod (if needed) to use is Mekanism with the gravity module in the chest piece. Spam space and the flight toggle (which is typically G I believe). You should wind up in a state where flying is true and mayFly is false on the server

Description of issue: This might be a timing issue, but the client is setting the flying to true, AFTER the server has turned everything off.

Soaryn avatar Aug 14 '24 20:08 Soaryn

Seemingly, adding the following after the existing code in ServerGamePacketListenerImpl in handlePlayerAbilities might be enough, at least from testing I've done.

   if (packet.isFlying() != this.player.getAbilities().flying)
            player.onUpdateAbilities();

Soaryn avatar Aug 15 '24 03:08 Soaryn