summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-07-13 06:52:40 +0100
committerDinnerbone <dinnerbone@dinnerbone.com>2011-07-13 10:44:03 +0100
commit3d28c67c081e80891d459b102646b956b612a581 (patch)
tree672fbd311777f2a637b1637a9bf5632a7cb1961a /src/main/java/org
parent7f6e7060d753a9ce6ca977191b21998dc1109f22 (diff)
downloadcraftbukkit-3d28c67c081e80891d459b102646b956b612a581.tar
craftbukkit-3d28c67c081e80891d459b102646b956b612a581.tar.gz
craftbukkit-3d28c67c081e80891d459b102646b956b612a581.tar.lz
craftbukkit-3d28c67c081e80891d459b102646b956b612a581.tar.xz
craftbukkit-3d28c67c081e80891d459b102646b956b612a581.zip
Implemented helper methods + new biome methods
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java51
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java46
2 files changed, 67 insertions, 30 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 7170a9be..8c47fa75 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -30,6 +30,7 @@ import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.TreeType;
import org.bukkit.World;
+import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
public class CraftWorld implements World {
@@ -488,6 +489,56 @@ public class CraftWorld implements World {
return populators;
}
+ public Block getHighestBlockAt(int x, int z) {
+ return getBlockAt(x, getHighestBlockYAt(x, z), z);
+ }
+
+ public Block getHighestBlockAt(Location location) {
+ return getHighestBlockAt(location.getBlockX(), location.getBlockZ());
+ }
+
+ public Biome getBiome(int x, int z) {
+ BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z);
+
+ if (base == BiomeBase.RAINFOREST) {
+ return Biome.RAINFOREST;
+ } else if (base == BiomeBase.SWAMPLAND) {
+ return Biome.SWAMPLAND;
+ } else if (base == BiomeBase.SEASONAL_FOREST) {
+ return Biome.SEASONAL_FOREST;
+ } else if (base == BiomeBase.FOREST) {
+ return Biome.FOREST;
+ } else if (base == BiomeBase.SAVANNA) {
+ return Biome.SAVANNA;
+ } else if (base == BiomeBase.SHRUBLAND) {
+ return Biome.SHRUBLAND;
+ } else if (base == BiomeBase.TAIGA) {
+ return Biome.TAIGA;
+ } else if (base == BiomeBase.DESERT) {
+ return Biome.DESERT;
+ } else if (base == BiomeBase.PLAINS) {
+ return Biome.PLAINS;
+ } else if (base == BiomeBase.ICE_DESERT) {
+ return Biome.ICE_DESERT;
+ } else if (base == BiomeBase.TUNDRA) {
+ return Biome.TUNDRA;
+ } else if (base == BiomeBase.HELL) {
+ return Biome.HELL;
+ } else if (base == BiomeBase.SKY) {
+ return Biome.SKY;
+ }
+
+ return null;
+ }
+
+ public double getTemperature(int x, int z) {
+ return getHandle().getWorldChunkManager().a((double[])null, x, z, 1, 1)[0];
+ }
+
+ public double getHumidity(int x, int z) {
+ return getHandle().getWorldChunkManager().getHumidity(x, z);
+ }
+
private final class ChunkCoordinate {
public final int x;
public final 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 7bc8578c..9adf897b 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -330,37 +330,15 @@ public class CraftBlock implements Block {
}
public Biome getBiome() {
- BiomeBase base = chunk.getHandle().world.getWorldChunkManager().getBiome(x, z);
-
- if (base == BiomeBase.RAINFOREST) {
- return Biome.RAINFOREST;
- } else if (base == BiomeBase.SWAMPLAND) {
- return Biome.SWAMPLAND;
- } else if (base == BiomeBase.SEASONAL_FOREST) {
- return Biome.SEASONAL_FOREST;
- } else if (base == BiomeBase.FOREST) {
- return Biome.FOREST;
- } else if (base == BiomeBase.SAVANNA) {
- return Biome.SAVANNA;
- } else if (base == BiomeBase.SHRUBLAND) {
- return Biome.SHRUBLAND;
- } else if (base == BiomeBase.TAIGA) {
- return Biome.TAIGA;
- } else if (base == BiomeBase.DESERT) {
- return Biome.DESERT;
- } else if (base == BiomeBase.PLAINS) {
- return Biome.PLAINS;
- } else if (base == BiomeBase.ICE_DESERT) {
- return Biome.ICE_DESERT;
- } else if (base == BiomeBase.TUNDRA) {
- return Biome.TUNDRA;
- } else if (base == BiomeBase.HELL) {
- return Biome.HELL;
- } else if (base == BiomeBase.SKY) {
- return Biome.SKY;
- }
+ return getWorld().getBiome(x, z);
+ }
- return null;
+ public double getTemperature() {
+ return getWorld().getTemperature(x, z);
+ }
+
+ public double getHumidity() {
+ return getWorld().getHumidity(x, z);
}
public boolean isBlockPowered() {
@@ -400,4 +378,12 @@ public class CraftBlock implements Block {
public int getBlockPower() {
return getBlockPower(BlockFace.SELF);
}
+
+ public boolean isEmpty() {
+ return getType() == Material.AIR;
+ }
+
+ public boolean isLiquid() {
+ return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
+ }
}