Get nearby coordinates (not entities)

Discussion in 'Plugin Development' started by JjPwN1, Mar 21, 2013.

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

    JjPwN1

    I am making a plugin that is quite like MobArena, spawning mobs when rounds change, lobbies before playing in an arena, etc.

    I have a decent way of spawning mobs, but instead of getting nearby mob spawn points, it spawns a mob at each mob spawn. I can't find a way to get a "cube" around a player, and search that cube for a set of coordinates. Sort of like WorldEdit?

    I use getMobSpawn(String arena, int spawn) to find a mob spawn (pa is the main class):
    Code:
    public Location getMobSpawn(String arena, int spawn){
            return new Location(Bukkit.getWorld("world"), pa.getConfig().getInt(arena + ".mobspawns." + spawn + ".x"), pa.getConfig().getInt(arena + ".mobspawns." + spawn + ".y"), pa.getConfig().getInt(arena + ".mobspawns." + spawn + ".z"));
    }
    So using getMobSpawn, and a loop, how can I get nearby mob spawns?
     
  2. Offline

    chasechocolate

    When you try to access an integer from the config, you should do a check to see if it exists (could throw a NullPointerException. For creating a cube, just add X, Y and Z values to the initial location.
     
  3. Offline

    JjPwN1

    I figured as much to create a cube, but how do you get a range of coordinates so you can see if it contains a certain set of coordinates?
     
  4. Offline

    chasechocolate

    When you loop through the blocks with a for-loop, save them to an ArrayList<Location>:
    Code:java
    1. <arraylist>.add(new Location(world, x, y, z));
     
Thread Status:
Not open for further replies.

Share This Page