[Solved] 1.8.3 NMS Skeleton Movement

Discussion in 'Spigot Plugin Development' started by belknapkid, May 26, 2015.

  1. Hi, I have a problem. You see, I am going to flat out admit that I am a noob when it comes to NMS. Don't worry though, I am very fluent with java. After reading tutorials on the interwebs to try and figure out how to get a mob to follow your movements, I think I have all the code right (I'll admit, I copy and pasted. Sorry for that!) yet my Eclipse IDE is saying that some variables are non-existent. I tried removing some stuff here and there as well as putting in random variables to see if that would work, but to no avail. In this piece of code, the variables aX, aY bH(), isStatic, and j are most likely nonexistent or represent a different value. I did a double check by decompiling the spigot 1.8.3 jar inside my project and all of the said variables are missing. Basically, I need to figure out what those missing variables actually are. Thanks!

    EDIT: Fixed all of them going into the EntityHorse class. We're all good!
    Code (Text):
     @Override
            public void g(float sideMot, float forMot) {
                if(this.passenger != null && this.passenger instanceof EntityHuman) {
                    this.lastYaw = this.yaw = this.passenger.yaw;
                    this.pitch = this.passenger.pitch * 0.5F;
                    this.setYawPitch(this.yaw, this.pitch);//Update the pitch and yaw
                    this.aI = this.aG = this.yaw;
                    sideMot = ((EntityLiving)this.passenger).aX * 0.5F;
                    forMot = ((EntityLiving)this.passenger).aY;
                    if(forMot <= 0.0F) {
                        forMot *= 0.25F;// Make backwards slower
                    }
     
                    Field jump = null; //Jumping
                    try {
                        jump = EntityLiving.class.getDeclaredField("aW");
                    } catch (NoSuchFieldException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (SecurityException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    jump.setAccessible(true);
     
                    if (jump != null && this.onGround) {    // Wouldn't want it jumping while on the ground would we?
                        try {
                            if (jump.getBoolean(this.passenger)) {
                                double jumpHeight = 0.5D;//Here you can set the jumpHeight
                                this.motY = jumpHeight;    // Used all the time in NMS for entity jumping
                            }
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
     
                    this.S = 1.0F;// The custom entity will now automatically climb up 1 high blocks
                    this.aK = this.bH() * 0.1F;
                    if(!this.world.isStatic) {
                        this.j(0.35F);//Here is the speed the entity will walk.
                        super.g(sideMot, forMot);
                    }
     
     
                    this.ay = this.az;//Some extra things
                    double d0 = this.locX - this.lastX;
                    double d1 = this.locZ - this.lastZ;
                    float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
                    if(f4 > 1.0F) {
                        f4 = 1.0F;
                    }
     
                    this.az += (f4 - this.az) * 0.4F;
                    this.aA += this.az;
                } else {
                    this.S = 0.5F;
                    this.aK = 0.02F;
                    super.g(sideMot, forMot);
                }
          }
     
    #1 belknapkid, May 26, 2015
    Last edited: May 26, 2015