1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Feature Make EntityDismountEvent cancellable

Discussion in 'Bugs & Feature Requests' started by SanX, May 4, 2015.

  1. I'm working on a plugin that would allow the player to ride squids and dive with them, but I've discovered that as soon as the player goes underwater, the server automatically dismounts it from the squid. There's a VehicleExitEvent that is cancellable, but only works for actual Vehicles. Then there is an EntityDismountEvent that works for other entities too, but there's no way to cancel it, so I can't keep the player from getting dismounted from the squid underwater.

    The first solution would be to make this event cancellable and add a DismountCause enum, so I can tell when the player manually gets off the squid.

    The second solution would be to just blacklist Squids or WaterMobs from the code where the passenger gets dismounted.
    EntityLiving.java, around line 210:
    Code (Text):
    if (!this.world.isClientSide && this.au() && this.vehicle instanceof EntityLiving) {
                        this.mount((Entity) null);
    Change it to:
    Code (Text):
    if (!this.world.isClientSide && this.au() && this.vehicle instanceof EntityLiving && !(this.vehicle instanceof EntitySquid)) {
                        this.mount((Entity) null);
    Sure I can mod the server on my own, but I better want it in the offical spigot so I don't have to merge my changes everytime I update.
    • Like Like x 8
  2. I like the idea!
    • Agree Agree x 2
  3. Definitely would like to see this
  4. It is cancellable.
    It must be... With I lot of extra code.
    Play Gravity on Mineplex, you have to ride bats. But you can't dismount them.
  5. Code (Text):
    public void onDismount(PlayerTeleportEvent e){
          Player player = e.getPlayer();
          if (player.getVehicle() != null && player.getVehicle()  instanceof Bat){
    PlayerTeleportEvent gets called when you mount and dismount. That's the method Mineplex is using I assume.

    But anyways. I support this idea :) I've come across a lot of cases where I really needed such a feature.