mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Keep Blocks updated when changed by the world
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
b0d5c9042a
commit
8c4820f75e
2 changed files with 19 additions and 2 deletions
|
@ -9,8 +9,8 @@ public class CraftBlock implements Block {
|
|||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private int type;
|
||||
private byte data;
|
||||
protected int type;
|
||||
protected 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue