Implemented CHUNK_LOADED

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
CraftBukkit/Spigot 2011-01-04 15:54:41 +00:00
parent 596035458a
commit 37bc03b43a

View file

@ -21,8 +21,8 @@ import org.bukkit.Vector;
import org.bukkit.World;
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 Map<ChunkCoordinate, CraftChunk> chunkCache = new HashMap<ChunkCoordinate, CraftChunk>();
private final Map<BlockCoordinate, CraftBlock> blockCache = new HashMap<BlockCoordinate, CraftBlock>();
private final WorldServer world;
private static final Random rand = new Random();
@ -33,7 +33,7 @@ public class CraftWorld implements World {
public Block getBlockAt(int x, int y, int z) {
BlockCoordinate loc = new BlockCoordinate(x, y, z);
Block block = blockCache.get(loc);
CraftBlock block = blockCache.get(loc);
if (block == null) {
block = new CraftBlock(this, x, y, z, world.a(x, y, z), (byte)world.b(x, y, z));
@ -49,7 +49,7 @@ public class CraftWorld implements World {
public Chunk getChunkAt(int x, int z) {
ChunkCoordinate loc = new ChunkCoordinate(x, z);
Chunk chunk = chunkCache.get(loc);
CraftChunk chunk = chunkCache.get(loc);
if (chunk == null) {
chunk = new CraftChunk(this, x, z);
@ -84,6 +84,20 @@ public class CraftWorld implements World {
return block;
}
public CraftChunk updateChunk(int x, int z) {
ChunkCoordinate loc = new ChunkCoordinate(x, z);
CraftChunk chunk = chunkCache.get(loc);
if (chunk == null) {
chunk = new CraftChunk(this, x, z);
chunkCache.put(loc, chunk);
} else {
// TODO: Chunk stuff
}
return chunk;
}
public WorldServer getHandle() {
return world;
}