Solved Flying transport problem(custom armorstand)

Discussion in 'Spigot Plugin Development' started by xQuipster, Jun 29, 2021.

Thread Status:
Not open for further replies.
  1. Hello everybody, has problem with creating a flying transport with armorstand using custom entities.

    Code (Java):
    public class FlyingTransport extends EntityArmorStand {
        public FlyingTransport(World world) {
            super(world);
            ArmorStand stand = (ArmorStand) this.getBukkitEntity();
            stand.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(10);
            stand.setGravity(false);
        }
        @Override
        public float g(float sideMot, float forMot) {
            if (this.passengers != null && this.passengers.size() > 0) {
                EntityLiving passenger = (EntityLiving) this.passengers.get(0);
                if(passenger instanceof EntityPlayer){
                    this.yaw = passenger.yaw;
                    this.lastYaw = this.yaw;
                    this.pitch = passenger.pitch;
                    this.lastPitch = pitch;
                    setYawPitch(this.yaw, this.pitch);
                    this.aN = this.yaw;
                    this.aP = this.aN;

                    Player player = ((EntityPlayer) passenger).getBukkitEntity();
                    ArmorStand stand = (ArmorStand) this.getBukkitEntity();

                 
                    Vector vector =                   player.getLocation().getDirection().subtract(player.getVelocity()).normalize().multiply(25);

                    stand.setVelocity(vector);

                    super.g(sideMot, forMot);
                }

            }
            return sideMot;
        }
    }
    Sorry for my bad english.
     
    #1 xQuipster, Jun 29, 2021
    Last edited: Jul 1, 2021
  2. You can't tell what the problem is just by providing the code.
     
  3. Sorry for this. Transport was spawned and rotating with player, but was not moving.
     
Thread Status:
Not open for further replies.