Pitch and Yaw not working in locations.

Discussion in 'Plugin Development' started by Muod, Apr 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Muod

    Okay so I have this code
    Code:
    public static String serializeLocation(Location l)
          {
            String s =  l.getWorld().getName() + ";" + l.getX() + ";" + l.getY() + ";" + l.getZ() + ";" + l.getPitch() + ";" + l.getYaw() + ";";
            return s;
          }
    and also
    Code:
    public static Location deserializeLocation(String s)
          {
            String toget = plugin.GemWars.getString(s);
            String[] args = toget.split(";");
               
                String worldS = args[0];
                String xS = args[1];
                String yS = args[2];
                String zS = args[3];
                String pitchS = args[4];
                String yawS = args[5];
                  World world = Bukkit.getWorld(worldS);
                  double x = Double.parseDouble(xS);
                  double y = Double.parseDouble(yS);
                  double z = Double.parseDouble(zS);
                  Float pitch = Float.valueOf(Float.parseFloat(pitchS));
                  Float yaw = Float.valueOf(Float.parseFloat(yawS));
                 
                  Location loc = new Location(world, x, y, z, pitch.floatValue(), yaw.floatValue());
                 
                  return loc;
            }
    Then to teleport I use
    p.teleport(deserializeLocation(plugin.GemWars.getString("Locations.ISPAWN")));
    Though that only teleports you to the correct place. The direction and place your looking is off. Anybody know why? I'm not getting errors
     
  2. Offline

    MineStein

    I am 99.9% sure you don't need the pitch and yaw. I recommend using this:
     
Thread Status:
Not open for further replies.

Share This Page