Check what biome a player is in?

Discussion in 'Plugin Development' started by jeffadkins51, Jul 19, 2011.

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

    jeffadkins51

    Is it possible to check what biome a player is in?
     
  2. Offline

    nisovin

    Something like this should work:

    player.getLocation().getBlock().getBiome();
     
  3. Offline

    jeffadkins51

    Oh duh... I just tried that a bit ago, but it does not seem to actually pick up the biomes. I believe you have to define them or something. Is there anyway to pickup the blocks around you within a certain radius and determine it that way? That was my original thought, but i seen problems with it.
     
  4. Offline

    loganwm

    That might get one position above the ground (which would be air)

    Code:
    player.getWorld().getBlockAt(player.getLocation().getBlockX(), player.getLocation().getBlockY()-1, player.getLocation().getBlockZ())
    That code should obtain the block directly underfoot; I'll leave the rest in your capable hands.
     
  5. Offline

    jeffadkins51

    That will not determine the biome. That'll just determine the block under the player's foot as said. Doing no good, as there is grass in the desert biome, sand in the tundra, etc. And grabbing multiple blocks could still mix the biomes causing problems.
     
  6. Offline

    loganwm

    Well, yes, it gets the block underfoot, then you get the biome data from that block. That's what I was referring to, not necessarily the block type.
     
  7. Offline

    CSharpRU

    Code:
    player.getWorld().getChunkAt(player.getLocation()).getBlock(0, 0, 0).getBiome();
    Try this, but 0.0.0 cords is wrong for this.
     
  8. Offline

    jeffadkins51

    Well what would be right for this? lol 1,1,1? Not great with coordinates.
     
  9. Offline

    CSharpRU

    I don't find any function without cords in.
     
  10. Offline

    loganwm

    Did you ever use the location that I provided in the earlier post? I've used it before to obtain biome data, and it will honestly save you a lot of trouble. Plug in the coordinates for the block under the player's feet, then get the biome data from that block.
     
  11. Offline

    jeffadkins51

    Could not get it to work. Like I said I'm very bad with locations, this includes coords.
     
  12. Offline

    loganwm

    Code:
    player.getWorld().getBlockAt(player.getLocation().getBlockX(), player.getLocation().getBlockY()-1, player.getLocation().getBlockZ()).getBiome()
    I'll send you the info for my test server and you can see it work.

    Edit: As per our talk, here's what you need:
    Code:
            Biome biomeData = player.getWorld().getBlockAt(player.getLocation().getBlockX(), player.getLocation().getBlockY()-1, player.getLocation().getBlockZ()).getBiome();
            if (biomeData == Biome.DESERT)
            {
                //do what you need to do
            }
     
Thread Status:
Not open for further replies.

Share This Page