Solved No Gravity + Velocity on Custom Entity

Discussion in 'Spigot Plugin Development' started by Etheus, Mar 31, 2020.

Thread Status:
Not open for further replies.
  1. Hi guys, haven't posted on here in a few years, but I'm playing around with making a sort of flying-horse-Pegasus plugin for an older version (1.13.2).

    Unfortunately, I'm experiencing the same issue seen here:

    Except with a horse - not an armor stand. Apparently, it has something to do with the NMS no clip and gravity, unfortunately, everything I've tried doesn't seem to work. The velocity is applied, but it stays stationary.
    Code (Java):
        public static class Pegasus extends EntityHorse {
            public Pegasus(World world) {


            public void c(float f, float f1) {

                if(!super.isNoGravity()) {
                    super.c(f, f1);
                } else {
                    move(EnumMoveType.SELF, motX, motY, motZ);
    //previously n
            public void tick() {
                if(!super.isNoGravity()) {
                    double motX = this.motX, motY = this.motY, motZ = this.motZ;
                    this.motX = motX;
                    this.motY = motY;
                    this.motZ = motZ;
                } else super.tick();
    Applying the velocity in c() at motY doesn't work, nor on a HorseJumpEvent
    Code (Text):
        public void onHorseJump(HorseJumpEvent e) {
            if(e.getEntity() instanceof Pegasus) {
                Entity pegasus = e.getEntity();
    //            pegasus.setVelocity(pegasus.getLocation().getDirection().multiply(0.75D));
                pegasus.setVelocity(new Vector(0, 0.75, 0));
    0.75 seems like the magic velocity number, and all I'm trying to do is launch the horse in the air a little bit for that mythological-Pegasus feel.
    #1 Etheus, Mar 31, 2020
    Last edited: Apr 2, 2020
  2. Hello,

    I had the same problem.. And the only way I found to fix it, it was to disable the AI before setting the velocity: Horse#setAI(false);
    If someone has a better idea..?
    • Informative Informative x 1
  3. Interesting! I just tested this, and yes, velocity does now get applied -- but, there is no jump bar and no ability to tame when horse AI is set to false.
  4. Although this wasn't a good solution for me, it seemed to be the best one. I've worked around it by using Horse#setTamed(true), and I also found out there was an issue with the NMS method I was using. Marking as solved.
Thread Status:
Not open for further replies.