neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://projects.neoforged.net/neoforged/neoforge
Other
1.14k stars 166 forks source link

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

Open Soaryn opened 1 month ago

Soaryn commented 1 month ago

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 commented 1 month ago

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();