Riding NMS entity not working

Discussion in 'Spigot Plugin Development' started by KingOfAdventure, May 14, 2015.

  1. Hi guys,

    I have a problem when trying to ride a NMS entity, when I use the following code, the player will ride the entity for the server but doesn't for the client self. When you try to move you will be set back to the entity in the riding position while you don't ride it as the client. Also, no entity ride packets will be send when this happens.
    I have tried using this code:

    Code (Text):
    ((EntityHuman) ((CraftPlayer) pl).getHandle()).mount(myCustomEntity);
    //And this
    myCustomEntity.getBukkitEntity().setPassenger(player);
    //And this where player is the org.bukkit.entity.Player class
    myNmsEntity.getBukkitEntity().setPassenger(player);
    My custom entity is :

    Code (Text):
    public class CustomEntityBlaze extends EntityBlaze{

       public CustomEntityBlaze(World world) {
             super(world);
             //All the attribute values from the craft bukkit source
       }
       //To double the velocity
       public void g(double d0, double d1, double d2) {
           this.motX += d0*2;
           this.motY += d1*2;
           this.motZ += d2*2;
       }
    }

    To spawn it :


    Code (Text):
    myNmsEntity = new CustomEntityBlaze(world);
    world.addEntity(myNmsEntity);
    myNmsEntity.setPosition(location.getX(),location.getY(),location.getZ());

    When I set a zombie as passenger the zombie rides the blaze normally.

    With all ways to set the player as passenger it still gives the same result as said above.

    Any help and ideas are helpful :)!