[SPIGOT-1588] Can't Cancel VehicleExitEvent Created: 01/Mar/16  Updated: 28/Jul/18  Resolved: 28/Jul/18

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Nathan Wolf Assignee: Unassigned
Resolution: Fixed Votes: 4
Labels: 1.9
Environment:

Spigot 1.9


Issue Links:
Duplicate
is duplicated by SPIGOT-2466 VehicleExitEvent seems broken Resolved
is duplicated by SPIGOT-4163 Inconsistent Behaviour Cancelling Ent... Resolved

 Description   

Cancelling the VehicleExitEvent no longer prevents the player from dismounting/exiting a vehicle/mount.



 Comments   
Comment by BillyGalbreath [ 27/Jul/18 ]

You can fix this by using reflection to re-set the rider's reference to the vehicle that gets lost during the cancelled event. For 1.13 this field is Entity#ax, to 1.12 it's Entity#au. For older versions you can look that up yourself.

public class TestPlugin extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void on(VehicleExitEvent event) {
        event.setCancelled(true);
        setVehicleBack(event.getExited(), event.getVehicle());
    }

    private void setVehicleBack(Entity rider, Entity vehicle) {
        try {
            Field ax = net.minecraft.server.v1_13_R1.Entity.class.getDeclaredField("ax");
            ax.setAccessible(true);
            ax.set(((CraftEntity) rider).getHandle(), ((CraftEntity) vehicle).getHandle());
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

See these for more information:

https://hub.spigotmc.org/jira/browse/SPIGOT-4113

https://hub.spigotmc.org/jira/browse/SPIGOT-4163

 

Comment by Nathan Wolf [ 01/Jul/16 ]

Nope. The client no longer waits for a response from the server before dismounting. It's basically client-driven now.

Comment by TheMrJezza [ 01/Jul/16 ]

I thought it was a server side issue. Not a client one.

Comment by Nathan Wolf [ 01/Jul/16 ]

This issue is due to client changes, there is nothing that can be done server side and I would not expect a fix.

That's my understanding of the problem, anyway.

Comment by TheMrJezza [ 01/Jul/16 ]

Not being able to cancel the VehicleExitEvent properly impacts plugins like WorldGuard for example. I really don't mean to sound impatient, but this issue was created in 1.9. And it's still here in 1.10.2.

Comment by KaareZ [ 31/Mar/16 ]

Bump

Generated at Fri Apr 11 15:51:16 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.