Get Location Near Player

Discussion in 'Plugin Development' started by PieMan456, Dec 1, 2013.

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

    PieMan456

    Hello Everyone,

    I am trying to make a landmine plugin. I set the landmine by shooting an egg at a block and a config file stores the location like this:
    Code:java
    1. double eggx = egg.getLocation().getBlockX();
    2. double eggy = egg.getLocation().getBlockY();
    3. double eggz = egg.getLocation().getBlockZ();
    4. getConfig().set("eggs.eggx." + egg.getLocation(), eggx);
    5. getConfig().set("eggs.eggy." + egg.getLocation(), eggy);
    6. getConfig().set("eggs.eggz." + egg.getLocation(), eggz);
    7. saveConfig();

    I want to know how to get if the player is like 1 0r 2 blocks next to that location in the PlayerMoveEvent so I can trigger an explosion. Thanks for any help!
     
  2. Offline

    willy00

    getNearbyEntities(2, 2, 2)
     
  3. Offline

    maxben34

    Just use egg.getLocation().getNearbyEntities(2,0,2);
     
  4. Offline

    PieMan456

    maxben34
    .getNearbyEntities doesn't work inside of the ProjectileHitEvent.

    willy00
    Up.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  5. Offline

    willy00

    Pieman

    what is "Up."???
     
  6. Offline

    PieMan456

    willy00
    Look up at the post above it.
     
  7. Offline

    fireblast709

    PieMan456 either spawn an entity like an arrow or experience orb and use the method, or loop over the players that are in that world and check .getLocation().distanceSquared(blockloc)
     
  8. Offline

    PieMan456

  9. Offline

    fireblast709

    if you already have a Location object:
    Code:java
    1. location.getWorld().spawnEntity(location, EntityType.<your type>);
     
Thread Status:
Not open for further replies.

Share This Page