Merge remote branch 'upstream/master'

This commit is contained in:
durron597 2011-01-02 22:31:39 -05:00
commit a712a74c23
2 changed files with 42 additions and 3 deletions

View File

@ -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);
}
@ -123,6 +137,15 @@ public class CraftBlock implements Block {
return type;
}
/**
* Gets the light level between 0-15
*
* @return light level
*/
public byte getLightLevel() {
return light;
}
/**
* Gets the block at the given face
*

View File

@ -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;
@ -18,6 +20,8 @@ public class CraftWorld implements World {
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) {
@ -84,6 +88,18 @@ public class CraftWorld implements World {
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() {
return "CraftWorld";