Catch Entity at given Location or Block

Discussion in 'Plugin Development' started by DerNerz, Jan 26, 2011.

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

    DerNerz

    Hello,

    as the title says, i try to get a reference to an entity who's placed arround a given location or on a block's face. (And, of course, do something with it) I crawled trough the javadocs for a while but the only way i found is, to watch if any entity fires some events near my location.

    Is there any other way to do so? Don't look like the best to me.

    Sorry 4 bad english, it's damn late. ;)
    --- merged: Jan 27, 2011 7:06 PM ---
    In the end, i solved it this way:

    Code:
    public  static ArrayList<Player> players = new ArrayList<Player>();
    
    public void onPlayerJoin(PlayerEvent e) {
      SimpleElevators.players.add(e.getPlayer());
    }
    
    public void someFunction(Block block){
      ArrayList<Player> players = SimpleElevators.players;
      for (int x = 0; x < players.size() ; x++){
      if(players.get(x).getLocation().getBlockX() == block.getLocation().getBlockX() &&
          players.get(x).getLocation().getBlockY() == block.getLocation().getBlockY() &&
          players.get(x).getLocation().getBlockZ() == block.getLocation().getBlockZ()
      )
    }
    }
    Maybe it's useful for someone. If there's a better way, i would be happy to know.
     
Thread Status:
Not open for further replies.

Share This Page