From f71e2b4ed3c6877b1a622d33afd80838d2fa9f35 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Sat, 8 Jan 2011 03:44:29 +0000 Subject: [PATCH] Implemented block.getBiome --- .../org/bukkit/craftbukkit/CraftBlock.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 1650e972b6..92b3ea2e58 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; +import net.minecraft.server.MobSpawnerBase; import org.bukkit.*; import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.block.CraftBlockState; @@ -265,4 +266,37 @@ public class CraftBlock implements Block { return new CraftBlockState(this); } } + + public Biome getBiome() { + // TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk + MobSpawnerBase base = world.getHandle().a().a(chunk.getX(), chunk.getZ()); + + if (base == MobSpawnerBase.a) { + return Biome.RAINFOREST; + } else if (base == MobSpawnerBase.b) { + return Biome.SWAMPLAND; + } else if (base == MobSpawnerBase.c) { + return Biome.SEASONAL_FOREST; + } else if (base == MobSpawnerBase.d) { + return Biome.FOREST; + } else if (base == MobSpawnerBase.e) { + return Biome.SAVANNA; + } else if (base == MobSpawnerBase.f) { + return Biome.SHRUBLAND; + } else if (base == MobSpawnerBase.g) { + return Biome.TAIGA; + } else if (base == MobSpawnerBase.h) { + return Biome.DESERT; + } else if (base == MobSpawnerBase.i) { + return Biome.PLAINS; + } else if (base == MobSpawnerBase.j) { + return Biome.ICE_DESERT; + } else if (base == MobSpawnerBase.k) { + return Biome.TUNDRA; + } else if (base == MobSpawnerBase.l) { + return Biome.HELL; + } + + return null; + } }