PaperMC / PaperMC/Paper

Can't properly cancel entity movement with passengers or for vehicles

Open
#11,633 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: accepted version: 1.21.3
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

Entity move event should be called even with passengers

Observed/Actual behavior

Vehicles can't enter unless steered into the region

Player movement is cancelled, but the mount can freely move

Mobs without passengers can't enter (intended)

Steps/models to reproduce
  1. Cancel player, vehicle and entity movement into a certain region
  2. Try to walk into the region (should and does not work)
  3. Try to push a mob or vehicle into the region (should and does not work)
  4. Steer a vehicle (horse, boat, pig, strider) into the region (glitches out like crazy because player movement is still called for some reason, but the player stays mounted, and the vehicle keeps moving)
  5. Steer a minecart into the region (should not, but does work. When dismounting, the player is teleported back to their supposed position)
Plugin and Datapack List

pl
[18:16:53 INFO]: Server Plugins (7):
[18:16:53 INFO]: Paper Plugins:
[18:16:53 INFO]: - Protect, ServiceIO, Tweaks, Worlds
[18:16:53 INFO]: Bukkit Plugins:
[18:16:53 INFO]: - FastAsyncWorldEdit, LuckPerms, WorldEditSUI

datapack list
[18:17:05 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[18:17:05 INFO]: There are no more data packs available

Paper version

ver
[18:17:16 INFO]: Checking version, please wait...
[18:17:16 INFO]: This server is running Paper version 1.21.3-35-master@4e01ede (2024-11-18T12:51:42Z) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
You are 1 version(s) behind
Download the new version at: https://papermc.io/downloads/paper
Previous version: 1.21.3-29-be886cf (MC: 1.21.3)

Other

My code for cancelling the movements

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
    if (!event.hasChangedBlock()) return;
    if (canMove(event.getPlayer(), event.getFrom(), event.getTo())) return;
    event.setCancelled(true);
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityMove(EntityMoveEvent event) {
    if (!event.hasChangedBlock()) return;
    if (canMove(event.getEntity(), event.getFrom(), event.getTo())) return;
    event.setCancelled(true);
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onVehicleMove(VehicleMoveEvent event) {
    if (canMove(event.getVehicle(), event.getFrom(), event.getTo())) return;
    // event.getVehicle().setVelocity(new Vector());
    event.getVehicle().teleport(event.getFrom());
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the listed vehicle, passenger, minecart, and entity cases with the PlayerMoveEvent, EntityMoveEvent, and VehicleMoveEvent handlers shown in the issue. Trace how movement cancellation and teleportation interact, then verify that blocked movement consistently prevents vehicles and passengers from entering the region without the reported glitches.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.