diff options
author | durron597 <martin.jared@gmail.com> | 2011-01-02 22:31:39 -0500 |
---|---|---|
committer | durron597 <martin.jared@gmail.com> | 2011-01-02 22:31:39 -0500 |
commit | a712a74c23642873f2e375da3e2a96bedbee7810 (patch) | |
tree | fe682a4d5b084c0952c1e85ac192d1374477b89b /src/main/java/org | |
parent | f4811846124859a732e46b01450b874f4b505f8e (diff) | |
parent | 31c5894743d1c0701de7d0d89184467a5a82e6d8 (diff) | |
download | craftbukkit-a712a74c23642873f2e375da3e2a96bedbee7810.tar craftbukkit-a712a74c23642873f2e375da3e2a96bedbee7810.tar.gz craftbukkit-a712a74c23642873f2e375da3e2a96bedbee7810.tar.lz craftbukkit-a712a74c23642873f2e375da3e2a96bedbee7810.tar.xz craftbukkit-a712a74c23642873f2e375da3e2a96bedbee7810.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftBlock.java | 23 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 22 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 38422d85..19dce3c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java @@ -11,6 +11,7 @@ public class CraftBlock implements Block { private final int z; protected int type; protected byte data; + protected byte light; protected CraftBlock(final CraftWorld world, final int x, final int y, final int z, final int type, final byte data) { this.world = world; @@ -19,6 +20,19 @@ public class CraftBlock implements Block { this.z = z; this.type = type; this.data = data; + this.light = (byte)world.getHandle().i(x, y, z); + this.chunk = (CraftChunk)world.getChunkAt(x << 4, z << 4); + } + + protected CraftBlock(final CraftWorld world, final int x, final int y, + final int z, final int type, final byte data, final byte light) { + this.world = world; + this.x = x; + this.y = y; + this.z = z; + this.type = type; + this.data = data; + this.light = light; this.chunk = (CraftChunk)world.getChunkAt(x << 4, z << 4); } @@ -122,6 +136,15 @@ public class CraftBlock implements Block { public int getTypeID() { return type; } + + /** + * Gets the light level between 0-15 + * + * @return light level + */ + public byte getLightLevel() { + return light; + } /** * Gets the block at the given face diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 1e072f0f..20fd62ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -3,9 +3,11 @@ package org.bukkit.craftbukkit; import java.util.HashMap; import java.util.Map; +import java.util.Random; +import net.minecraft.server.WorldGenBigTree; +import net.minecraft.server.WorldGenTrees; import net.minecraft.server.WorldServer; import net.minecraft.server.EntityArrow; - import org.bukkit.ArrowEntity; import org.bukkit.Block; import org.bukkit.Chunk; @@ -17,6 +19,8 @@ public class CraftWorld implements World { private final Map<ChunkCoordinate, Chunk> chunkCache = new HashMap<ChunkCoordinate, Chunk>(); private final Map<BlockCoordinate, Block> blockCache = new HashMap<BlockCoordinate, Block>(); private final WorldServer world; + + private static final Random rand = new Random(); public CraftWorld(WorldServer world) { this.world = world; @@ -50,8 +54,8 @@ public class CraftWorld implements World { return getChunkAt(block.getX() << 4, block.getZ() << 4); } - public boolean isChunkLoaded() { - throw new UnsupportedOperationException("Not supported yet."); + public boolean isChunkLoaded(Chunk chunk) { + return world.A.a(chunk.getX(), chunk.getZ()); } public Block updateBlock(int x, int y, int z) { @@ -83,6 +87,18 @@ public class CraftWorld implements World { arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); return new CraftArrowEntity(world.getServer(), arrow); } + + public boolean generateTree(Location loc) { + WorldGenTrees treeGen = new WorldGenTrees(); + return treeGen.a(world, rand, + loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + + public boolean generateBigTree(Location loc) { + WorldGenBigTree treeGen = new WorldGenBigTree(); + return treeGen.a(world, rand, + loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } @Override public String toString() { |