Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5810

Wrong "onGround" state

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 1.16
    • Yes

      ----------------------------------------------------------

      Here are three possible ways to fix it:

      #1: Do not call the `EntityPlayer#move()` method before PlayerMoveEvent is triggered. This is exactly what happened in 1.8 spigot. (I've explained it to you on discord)

      #2: As before 1.15, update the player's onGround status after calling the move() method. This ensures plugin compatibility. (But as you said, "the old behavior was arguably a bug")

      #3: The most elegant solution is to add "fromGround" and "toGround" fields in PlayerMoveEvent and add new constructors. 
      Here is a fake code:

      // Fake Code (at PlayerConnection.class)
      boolean toGround = flyingPacket.onGround;
      boolean fromGround = this.previousGround;
      this.previousGround = flyingPacket.onGround;
      
      PlayerMoveEvent event = new PlayerMoveEvent(..., fromGround, toGround);
      Bukkit.getPluginManager().callEvent(event);

       

      -----------------------------------------------------------

      Before 1.16:

      1.16:

      Why it's important:

      Some plugins need to determine whether the player is on the ground in PlayerMoveEvent. If you do not update the ground state before PlayerMoveEvent is triggered, the plugin will get the wrong ground state

            Unassigned Unassigned
            RERERE RJL
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: