Paper icon indicating copy to clipboard operation
Paper copied to clipboard

PlayerMoveEvent is not always called

Open Leguan16 opened this issue 3 years ago • 13 comments

Expected behavior

I recently discovered that the PlayerMoveEvent does not trigger when moving in a minecart or on a llama. But due to the fact that it triggers when moving in a boat I also expect it to trigger when moving in a minecart.

Observed/Actual behavior

It does not trigger the event when moving in a minecart or on a llama.

Steps/models to reproduce

Just to show if a player is moving or not:

@EventHandler
public void onMove(PlayerMoveEvent event) {
    System.out.println("MOVE");
}

Hop in a minecart and you will see that it does not trigger the event. If you hop in a boat and move it will trigger the event.

Plugin and Datapack List

just the plugin with the handler.

Paper version

This server is running Paper version git-Paper-317 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: e5da93a) You are running the latest version Previous version: git-Paper-302 (MC: 1.18.2)

Other

No response

Leguan16 avatar May 04 '22 18:05 Leguan16

The fact that it triggers in a boat sounds like the actual bug here The player isn't moving, the vehicle that they're riding is, is the notation here

electronicboy avatar May 04 '22 19:05 electronicboy

Does the boat move event get triggered on Spigot?

HexedHero avatar May 04 '22 19:05 HexedHero

Which boat move event?

Leguan16 avatar May 05 '22 05:05 Leguan16

Ideally we would call the move event, but only with rotational values, or create a new event for (relative) rotation changes inside of a vehicle ... if you're only looking for x,y,z coordinate changes, you need to listen to VehicleMoveEvent

kennytv avatar May 05 '22 07:05 kennytv

Personally I would expect player move event to be fired as well as the player is changing positions. You can get the vehicle from a player with Player#getVehicle() as well. This method wouldn't be there if this event isn't supposed to be fired when moving in a vehicle?

--edit-- just checked the javadocs for Vehicle Entities. Vehicle all subinterfaces are: AbstractHorse, Boat, ChestedHorse, CommandMinecart, Donkey, ExplosiveMinecart, HopperMinecart, Horse, Llama, Minecart, Mule, Pig, PoweredMinecart, RideableMinecart, SkeletonHorse, SpawnerMinecart, StorageMinecart, Strider, TraderLlama, ZombieHorse

The PlayerMoveEvent is called for moving with every single vehicle with the exception of minecarts and llamas

BuzzardM avatar May 05 '22 13:05 BuzzardM

It has already been reported back in 2019 https://hub.spigotmc.org/jira/browse/SPIGOT-4568

Leguan16 avatar May 09 '22 13:05 Leguan16

Then it would be better to create an event that fires when an entity called EntityMoveEvent rather than PlayerMoveEvent moves. PlayerMoveEvent means the player moves directly.

MinecraftUserHAN1110 avatar May 13 '22 11:05 MinecraftUserHAN1110

Maybe a PlayerMoveInVehicleEvent?

Leguan16 avatar May 14 '22 17:05 Leguan16

VehicleMoveEvent maybe?

Iuriiiii avatar May 18 '22 21:05 Iuriiiii

Did you write that because ”it already exists”?

Leguan16 avatar May 18 '22 21:05 Leguan16

Hum

sebastianjnuwu avatar May 21 '22 13:05 sebastianjnuwu

Generally speaking, this issue appears for any vehicle that considers the player the controlling passenger. Spigot actively just calls move events for any of these (see here).

Also see https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/net/minecraft/server/network/PlayerConnection.patch#262.

Hence, PlayerMoveEvents are called for all of the following entities:

  • Boat
  • Horse (all sub types but llama)
  • Pig
  • Ravager
  • Strider

// edit: How to solve this is up to whoever works on this. Calling player move events for every passanger would be doable by just listening to the vehicle move packet, however that is a philosophical question and I'd prefer if we had proper events for players moving inside or on top of vehicle instead.

lynxplay avatar Aug 06 '22 23:08 lynxplay

Would that new event then be called instead of the PlayerMoveEvent or additionally. I feel it should be consistent between all kind of vehicles that if you move inside/with it the same event gets called. No matter if you are steering the vehicle or not.

Leguan16 avatar May 04 '23 17:05 Leguan16