Keep Blocks updated when changed by the world

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
CraftBukkit/Spigot 2010-12-28 23:52:29 +00:00
parent b0d5c9042a
commit 8c4820f75e
2 changed files with 19 additions and 2 deletions

View File

@ -9,8 +9,8 @@ public class CraftBlock implements Block {
private final int x; private final int x;
private final int y; private final int y;
private final int z; private final int z;
private int type; protected int type;
private byte data; protected byte data;
protected CraftBlock(final World world, final int x, final int y, final int z, final int type, final byte data) { protected CraftBlock(final World world, final int x, final int y, final int z, final int type, final byte data) {
this.world = world; this.world = world;

View File

@ -49,6 +49,23 @@ public class CraftWorld implements World {
throw new UnsupportedOperationException("Not supported yet."); 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 { private final class ChunkCoordinate {
public final int x; public final int x;
public final int z; public final int z;