Solved Help with locations

Discussion in 'Plugin Development' started by Permeer, Jan 2, 2015.

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

    Permeer

    • Theres a long time that i dont code , so i'm doing a choose system and I need to check if the locations match but the cords of some locations simply change. Theres a part of the code
    To check if the locations match:
    Code:
    Location l = new Location(n.getLocation().getWorld(), n.getLocation().getX() + 0.5D, n.getLocation().getY(), n.getLocation().getZ() + 1.5D);
    
                    p.sendMessage("§c" + l);
    
                    if (l.getX() == loc.getX() && l.getY() == loc.getY() && l.getZ() == loc.getZ()) {
                        p.sendMessage("§cVoce escolheu o kit §c" + n.getName());
                        return;
                    }
    and the location that you need to click to choose

    Code:
    Location a = newLoc(996.0D, 5.0D, 580.5D);
     
  2. Offline

    nj2miami

    Hmm, not sure I see what the question is exactly. What are you trying to do or solve for?

    What does "n" represent? You are grabbing a new location based off it.
    Also, you are comparing this new Location l to a Location loc, what is that?
    Finally, you have a Location a in your next statement.

    A bit confusing, please clear it up and then I'll see what I can do :)
     
  3. Offline

    97WaterPolo

    @Permeer
    So I hate comparing Locations to Locations due to the offset that sometimes occurs and the lack of accurateness of it (In my opinion), so what I would recommend is "if (loc1.distance(loc2) <= .5)" then run your code.
     
Thread Status:
Not open for further replies.

Share This Page