Solved Yaw update not working

Discussion in 'Spigot Plugin Development' started by Joren2087, Feb 19, 2020.

Thread Status:
Not open for further replies.
  1. Hey folks

    I'm having a lot of trouble with rotating (aka changing the yaw of) an already spawned armorstand.

    I've tried a lot of things but none of them worked for me:

    • Changing the yaw of the location and teleporting the armorstand to the new location
    • Checked the values so they all are in degrees
    • Tried to change the body y axis, this worked only for the body part and not for the whole armorstands (same for other parts of the armorstand)
    • Changed the yaw and positions via craftbukkit and teleport the armorstand (via craftbukkit)

    I've even tried custom packets. This worked, but isn't usable in my case and messing with packets isn't always a smart/good way of dealing with this.

    So, does anyone know what I'm doing wrong or is it just a weird bug?

    Any help is appreciated!
     
  2. Cloning the location and modifying the yaw then teleporting the entity with that location should have worked. Could you provide some code for how you did it?
     
  3. @Esophose That's the first thing I've tried but did not work. I will post the used code later today.

    @ShaneBee That method is deprecated and did not work for me.
     
  4. I had the same issue (regardless in 1.12.2) but my solution was your first tried one. The error I found was that I was somehow using different locations(they did the same thing it was just not the exact same one) rather than the same one for teleporting and setting the yaw.
     
  5. @Esophose
    Here is the code I used, it's a bit sketchy, but only for testing pruposes.

    Code (Java):
                double x = Math.toRadians(Double.parseDouble(args[1]));
                double y = Math.toRadians(Double.parseDouble(args[2]));
                double z = Math.toRadians(Double.parseDouble(args[3]));

                double pitch = Double.parseDouble(args[4]);
                double yaw = Double.parseDouble(args[5]);

                boolean yawLater = args.length > 6 && args[6].equalsIgnoreCase("true");

                Location loc = lastLoc == null ? ((Player) sender).getLocation() : lastLoc;
                lastLoc = loc;
                loc.setYaw(yawLater ? 0 : (float) yaw);
                loc.setPitch((float) pitch);

                if(stand == null || args.length > 7 && args[7].equalsIgnoreCase("override") || stand.isDead()) {
                    stand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
                }

                stand.setHeadPose(new EulerAngle(x,y,z));

                stand.setGravity(false);

                ItemStack item = new ItemStack(Material.DIAMOND_HOE);
                ItemMeta meta = item.getItemMeta();
                ((Damageable) meta).setDamage(2);
                item.setItemMeta(meta);

                stand.setHelmet(item);

                if(yawLater) {

                    Location loc2 = stand.getLocation();
                    loc2.setYaw((float) yaw);

                    stand.teleport(loc2);
                    System.out.println("teleported");

                }

                sender.sendMessage("Spawned at " + loc);
                sender.sendMessage("Entity out: " + stand.getLocation());
     
    The "teleported" outprint does appear in the console, but the stands rotation/yaw stays 0.

    EDIT: Weird enough the yaw does update when I run the yawlater clause when an armorstand is already placed with a previous command. It won't update when I run the command just once.
     
  6. So, it has been 2 days and I didn't find a solution (yet). Does anyone have any ideas how to fix this?
     
  7. Somehow I managed to get it working using craftbukkit directly instead of the spigot API. It also could be that I was giving radian numbers instead of degree numbers.
     
Thread Status:
Not open for further replies.