Keep Blocks updated when changed by the world

This commit is contained in:
Dinnerbone
2010-12-28 23:52:29 +00:00
parent ef622b20d1
commit 804b5e7d2b
3 changed files with 135 additions and 2 deletions

View File

@@ -49,6 +49,23 @@ public class CraftWorld implements World {
throw new UnsupportedOperationException("Not supported yet.");
}
public Block updateBlock(int x, int y, int z) {
BlockCoordinate loc = new BlockCoordinate(x, y, z);
CraftBlock block = (CraftBlock)blockCache.get(loc);
final int type = world.a(x, y, z);
final byte data = (byte)world.b(x, y, z);
if (block == null) {
block = new CraftBlock(this, x, y, z, type, data);
blockCache.put(loc, block);
} else {
block.type = type;
block.data = data;
}
return block;
}
private final class ChunkCoordinate {
public final int x;
public final int z;