Solved ProtocolLIB | Set yaw of armorstand in STEER_VEHICLE

Discussion in 'Spigot Plugin Development' started by MaveCrit, May 11, 2017.

  1. Hey there,
    I'm currently playing around with WASD entity controls.
    Of course I'm doing pretty well but I have one last big problem.
    I cannot modify the yaw or well not permanent. It seems like STEER_VEHICLE replaces the yaw every tick.
    Has anyone a solution for this problem?

    Current state GIF:
    Click me

    My current code (taken from Afterburner0128 and updated to a working version):

    Code (Text):
    public void onPacketReceiving(PacketEvent event) {
            if (event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE && event.getPlayer().getVehicle() instanceof ArmorStand) {
               
                ArmorStand seat = (ArmorStand) event.getPlayer().getVehicle();
                if(!Main.getcar.containsKey(seat)){
                    return;
                }
                ArmorStand car = Main.getcar.get(seat);

                if (!(seat.getPassenger() instanceof Player)) {
                    return;
                }
                Player p = (Player) seat.getPassenger();
               
                if (forward) { // Forward[W]          
                        float yaw = event.getPlayer().getEyeLocation().getYaw();
                        float pitch = event.getPlayer().getEyeLocation().getPitch();
                        ((CraftArmorStand) car).teleport(new Location(car.getWorld(),car.getLocation().getX(),car.getLocation().getY(),car.getLocation().getZ(),yaw,pitch));
                        ((CraftArmorStand) seat).teleport(new Location(car.getWorld(),car.getLocation().getX(),car.getLocation().getY(),car.getLocation().getZ(),yaw,pitch));
                     
                        ((CraftArmorStand) seat).getHandle().i(yaw);
                        ((CraftArmorStand) seat).getHandle().h(yaw);
                       
                        ((CraftArmorStand) car).getHandle().i(yaw);
                        ((CraftArmorStand) car).getHandle().h(yaw);
    }
     
  2. Bump? :C
    Maybe someone can help me?
     
  3. I tried it using V3f which worked.
    So anyone who encounter the same issue: Simply use Vec3f and set it with the DataWatcher
     
  4. hxw

    hxw

    If any codes will help..
    I look for this question some times, but use STEER_VEHICLE in protocollib like PacketPlayInSteerVehicle in NMS, they not have any object type similar DataWatcher..
    May i missed something?