From fe34bbbb10cbf6f95b49d565e16562f9c12e8b7e Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 2 Jan 2011 18:30:46 -0800 Subject: [PATCH 1/4] Block.getLightLevel() --- .../org/bukkit/craftbukkit/CraftBlock.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 43ca3fbaa6..77407749d9 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 int getLightLevel() { + return light; + } /** * Gets the block at the given face From b2812b74d4a9c4646f72f9608cf660abede09427 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 2 Jan 2011 18:01:17 -0800 Subject: [PATCH 2/4] Added world.spawnTree(), world.spawnBigTree(). --- .../org/bukkit/craftbukkit/CraftWorld.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 1e072f0f18..25a7bd18dc 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 chunkCache = new HashMap(); private final Map blockCache = new HashMap(); private final WorldServer world; + + private static final Random rand = new Random(); public CraftWorld(WorldServer world) { this.world = world; @@ -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() { From 7ecc3d5b4b76de0f3b65de29eb184e0e3c132763 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Mon, 3 Jan 2011 03:25:24 +0000 Subject: [PATCH 3/4] Fixed isChunkLoaded(Chunk chunk) --- src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 25a7bd18dc..20fd62ade1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -54,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) { From 31c5894743d1c0701de7d0d89184467a5a82e6d8 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Mon, 3 Jan 2011 03:25:58 +0000 Subject: [PATCH 4/4] Light levels are bytes --- src/main/java/org/bukkit/craftbukkit/CraftBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 77407749d9..4b0520a917 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftBlock.java @@ -138,11 +138,11 @@ public class CraftBlock implements Block { } /** - * Gets the light level between 0-15. + * Gets the light level between 0-15 * * @return light level */ - public int getLightLevel() { + public byte getLightLevel() { return light; }