From 9a7f982668168aa8b634ebcc53a6d42433719708 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 2 Jan 2011 18:30:46 -0800 Subject: [PATCH 1/4] Block.getLightLevel() By: sk89q --- .../org/bukkit/craftbukkit/CraftBlock.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 43ca3fbaa6..77407749d9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/paper-server/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 8d1eea196c6446937f4ef8a3d2847e46163d3d3c Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 2 Jan 2011 18:01:17 -0800 Subject: [PATCH 2/4] Added world.spawnTree(), world.spawnBigTree(). By: sk89q --- .../org/bukkit/craftbukkit/CraftWorld.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 1e072f0f18..25a7bd18dc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/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 40fe64d5d79b6b84a96cab0f4f0c8e81e143763b Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 3 Jan 2011 03:25:24 +0000 Subject: [PATCH 3/4] Fixed isChunkLoaded(Chunk chunk) By: Dinnerbone --- .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 25a7bd18dc..20fd62ade1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/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 734b691ee8c160e3e1784454994ec5771317658d Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 3 Jan 2011 03:25:58 +0000 Subject: [PATCH 4/4] Light levels are bytes By: Dinnerbone --- .../src/main/java/org/bukkit/craftbukkit/CraftBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java index 77407749d9..4b0520a917 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftBlock.java +++ b/paper-server/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; }