Solved Controlling mobs you are riding?

Discussion in 'Plugin Development' started by WD_MUFFINFLUFFER, Jul 23, 2014.

Thread Status:
Not open for further replies.
  1. I am making a SIMPLE pets plugin and I have everything from naming them to having them follow you etc. The last thing I need is to have the player be able to control them while riding. Right now they can ride it however they can not control where the mobs goes and I was wondering if anyone can point me in the right direction?
    Thanks
     
  2. Offline

    Traks

  3. Offline

    Traks

    Yes, there is no way to do such a thing with plain Bukkit.
     
  4. Traks so I'm having some trouble with it, I mount the skeleton but can't control it.
    For this portion
    Code:java
    1. for (BiomeBase biomeBase : BiomeBase.biomes()){
    2. if (biomeBase == null){
    3. break;
    4. }
    5. //more stuff after this


    BiomeBase.biomes gave an error so I changed that to BiomeBase.n()
    Also every time this appeared \/ I got an error
    Code:java
    1. for (CustomEntityType entity : values()){

    So I changed that to
    Code:java
    1. for (CustomEntityType entity : CustomEntityType.values()){

    I went to the main class and I made sure to run
    Code:java
    1. CustomEntitySkeleton.registerEntities();

    But it doesnt work, any help on why?

    Heres the move method aswell

    Code:java
    1. @Override
    2. public void e(float sideMot, float forMot) {
    3. if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
    4. super.e(sideMot, forMot);
    5. this.W = 0.5F; //the entity can walk over half slabs instead of jumping
    6. return;
    7. }
    8.  
    9. this.lastYaw = this.yaw = this.passenger.yaw;
    10. this.pitch = this.passenger.pitch * 0.5F;
    11.  
    12. //entity's pitch, yaw, head rotation
    13. this.b(this.yaw, this.pitch);
    14. this.aO = this.aM = this.yaw;
    15.  
    16. this.W = 1.0F; //climb up 1 high blocks
    17.  
    18. sideMot = ((EntityLiving) this.passenger).bd * 0.5F;
    19. forMot = ((EntityLiving) this.passenger).be;
    20.  
    21. if (forMot <= 0.0F) {
    22. forMot *= 0.25F; //backwards slower
    23. }
    24. sideMot *= 0.75F; //sideways slower
    25.  
    26. float speed = 0.5F; //0.2 is the default entity speed.
    27. this.i(speed); //apply speed
    28. super.e(sideMot, forMot); //apply the motion to the entity
    29. }


    Also I get this error
    Code:java
    1. 23.07 21:31:24 [Server] WARN java.lang.reflect.InvocationTargetException

    on this line
    Code:java
    1. a.invoke(null, entity.getCustomClass(), entity.getName(), entity.getID());

    from this part of the code
    Code:java
    1. public static void registerEntities() {
    2. for (CustomEntityType entity : CustomEntityType.values()){
    3. try{
    4. Method a = EntityTypes.class.getDeclaredMethod("a", new Class<?>[]{Class.class, String.class, int.class});
    5. a.setAccessible(true);
    6. a.invoke(null, entity.getCustomClass(), entity.getName(), entity.getID());
    7. }catch (Exception e){
    8. e.printStackTrace();
    9. }
    10. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    Luke_Lax

    Could you not compromise and set the velocity of the mob based on where the player is looking? Just a suggestion :)
     
  6. Offline

    xTigerRebornx

    WD_MUFFINFLUFFER It seems you've missed some huge chunks of the tutorial. That, and you are trying to use reflection without knowing how. Go read up on reflection and how it works, and re-look at that tutorial.
     
    xTrollxDudex likes this.
Thread Status:
Not open for further replies.

Share This Page