Distance from a sethome

Discussion in 'Plugin Development' started by Jozeth, Aug 9, 2012.

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

    Jozeth

    How can I get the distance from a sethome?

    Example:
    Home:
    x:100
    y:64
    z:-232
     
  2. You have to get the location from the home and its player. After that compare both locations to get the distance.
     
    Jozeth likes this.
  3. Offline

    Kodfod


    Code:JAVA
    1. int x = Bukkit.getPlayer("SomePlayer").getLocation().getBlockX();
    2. int y = Bukkit.getPlayer("SomePlayer").getLocation().getBlockY();
    3. int z = Bukkit.getPlayer("SomePlayer").getLocation().getBlockZ();
    4. World world = Bukkit.getPlayer("SomePlayer").getLocation().getWorld();
    5. int hx = getConfig().getInt("Player.Home.X");
    6. int hy = getConfig().getInt("Player.Home.y");
    7. int hz = getConfig().getInt("Player.Home.z");
    8. String hworld = getConfig().getString("Player.Home.world");
    9. int dx = x-hx;
    10. int dy = y-hy;
    11. int dz = z-hz;
    12. System.out.println("The Distance is: X: " + dx + " Y: " + dy + " Z: " + dz + " In world: " + hworld);
    13.  
    14.  
     
    Jozeth likes this.
  4. Offline

    pzxc

    .... or just location1.distance(location2)
     
Thread Status:
Not open for further replies.

Share This Page