mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Keep Blocks updated when changed by the world
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
b0d5c9042a
commit
8c4820f75e
@ -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;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user