Solved Checking if player is in a specific biome??

Discussion in 'Plugin Development' started by creepers84, Mar 12, 2014.

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

    creepers84

    How would I check if the player is in a specific biome?
    Like: if(player.getLocation().getBiome == Forest)
    for instance????
     
  2. Offline

    Amgis

    creepers84
    Code:java
    1. public boolean isInBiome(Player player, Biome biome) {
    2.  
    3. return player.getLocation().getBlock().getBiome().equals(biome);
    4. }
     
    creepers84 likes this.
  3. Offline

    creepers84

    Amgis
    So I can shorten it and do this:
    Code:java
    1. if(player.getLocation().getBlock().getBiome().equals(Biome.FOREST)){
    ?
     
  4. Offline

    Amgis

    creepers84

    Yes. That was just a generic function that accepts any player and any biome.

    Your line of code will return true if and only if player is in a forest.
     
    creepers84 likes this.
  5. Offline

    creepers84

    Great. Thanks :)
     
    Amgis likes this.
Thread Status:
Not open for further replies.

Share This Page