diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 1634072cb6..0038c565b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -216,7 +216,9 @@ public class CraftChunk implements Chunk { if (includeBiome) { biome = new BiomeBase[256]; - wcm.getBiomeBlock(biome, x << 4, z << 4, 16, 16); + for (int i = 0; i < 256; i++) { + biome[i] = chunk.a(i & 0xF, i >> 4, wcm); + } } if (includeBiomeTempRain) { @@ -250,7 +252,9 @@ public class CraftChunk implements Chunk { if (includeBiome) { biome = new BiomeBase[256]; - wcm.getBiomeBlock(biome, x << 4, z << 4, 16, 16); + for (int i = 0; i < 256; i++) { + biome[i] = world.getHandle().getBiome((x << 4) + (i & 0xF), (z << 4) + (i >> 4)); + } } if (includeBiomeTempRain) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 6b9553ebd6..94f3874770 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -39,7 +39,6 @@ import org.bukkit.Bukkit; import org.bukkit.generator.ChunkGenerator; import org.bukkit.ChunkSnapshot; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.TreeType; import org.bukkit.World; import org.bukkit.block.Biome; @@ -48,7 +47,6 @@ import org.bukkit.Difficulty; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.plugin.messaging.StandardMessenger; -import org.bukkit.potion.Potion; public class CraftWorld implements World { private final WorldServer world; @@ -491,9 +489,19 @@ public class CraftWorld implements World { } public Biome getBiome(int x, int z) { - BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z); + return CraftBlock.biomeBaseToBiome(this.world.getBiome(x, z)); + } - return CraftBlock.biomeBaseToBiome(base); + public void setBiome(int x, int z, Biome bio) { + BiomeBase bb = CraftBlock.biomeToBiomeBase(bio); + if (this.world.isLoaded(x, 0, z)) { + net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(x, z); + + if (chunk != null) { + byte[] biomevals = chunk.l(); + biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id; + } + } } public double getTemperature(int x, int z) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index ec8d156a87..368cea9959 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -31,6 +31,7 @@ public class CraftBlock implements Block { private final int y; private final int z; private static final Biome BIOME_MAPPING[]; + private static final BiomeBase BIOMEBASE_MAPPING[]; public CraftBlock(CraftChunk chunk, int x, int y, int z) { this.x = x; @@ -248,6 +249,10 @@ public class CraftBlock implements Block { return getWorld().getBiome(x, z); } + public void setBiome(Biome bio) { + getWorld().setBiome(x, z, bio); + } + public static Biome biomeBaseToBiome(BiomeBase base) { if (base == null) { return null; @@ -256,6 +261,13 @@ public class CraftBlock implements Block { return BIOME_MAPPING[base.id]; } + public static BiomeBase biomeToBiomeBase(Biome bio) { + if (bio == null) { + return null; + } + return BIOMEBASE_MAPPING[bio.ordinal()]; + } + public double getTemperature() { return getWorld().getTemperature(x, z); } @@ -378,6 +390,7 @@ public class CraftBlock implements Block { /* Build biome index based lookup table for BiomeBase to Biome mapping */ static { BIOME_MAPPING = new Biome[BiomeBase.biomes.length]; + BIOMEBASE_MAPPING = new BiomeBase[Biome.values().length]; BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND; BIOME_MAPPING[BiomeBase.FOREST.id] = Biome.FOREST; BIOME_MAPPING[BiomeBase.TAIGA.id] = Biome.TAIGA; @@ -407,6 +420,9 @@ public class CraftBlock implements Block { if ((BiomeBase.biomes[i] != null) && (BIOME_MAPPING[i] == null)) { throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + "]"); } + if (BIOME_MAPPING[i] != null) { /* Build reverse mapping for setBiome */ + BIOMEBASE_MAPPING[BIOME_MAPPING[i].ordinal()] = BiomeBase.biomes[i]; + } } }