Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved how can I check if a villager is in the vicinity of a player

Comments in 'Plugin Development' started by cake23, Apr 24, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Hey! How can I check if a villager is in the vicinity of a player? For example from a radius of 5 blocks. So if a villager is in the vicinity of a player (for example 5 blocks away), the player get a message.
    Thanks!! :D
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Look at aliulys Plugin GoldStd
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $dis $player->distance($villager);
    if(
    $dis <= 5){
    // do something
    }
    While $player is your player and $villager your villager. (You might also wanna try distanceSquared)
    Skullex, Nawaf_Craft1b and cake23 like this.
  4. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thanks!! :D

Share This Page

Advertisement