PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.93k stars 2.3k forks source link

PlayerMoveEvent is not always called #7791

Open Leguan16 opened 2 years ago

Leguan16 commented 2 years ago

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

electronicboy commented 2 years ago

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

HexedHero commented 2 years ago

Does the boat move event get triggered on Spigot?

Leguan16 commented 2 years ago

Which boat move event?

kennytv commented 2 years ago

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

BuzzardM commented 2 years ago

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

Leguan16 commented 2 years ago

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

MinecraftUserHAN1110 commented 2 years ago

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.

Leguan16 commented 2 years ago

Maybe a PlayerMoveInVehicleEvent?

Iuriiiii commented 2 years ago

VehicleMoveEvent maybe?

Leguan16 commented 2 years ago

Did you write that because ”it already exists”?

sebastianjnuwu commented 2 years ago

Hum

lynxplay commented 2 years ago

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:

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

Leguan16 commented 1 year ago

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.