mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 04:05:50 -07:00
Optimized blockCache, now only stores blocks asked for
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
@@ -83,20 +83,22 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Block updateBlock(int x, int y, int z) {
|
public void updateBlock(int x, int y, int z, Integer type, Integer data) {
|
||||||
BlockCoordinate loc = new BlockCoordinate(x, y, z);
|
BlockCoordinate loc = new BlockCoordinate(x, y, z);
|
||||||
CraftBlock block = (CraftBlock)blockCache.get(loc);
|
CraftBlock block = (CraftBlock) blockCache.get(loc);
|
||||||
final int type = world.getTypeId(x, y, z);
|
|
||||||
final byte data = (byte)world.getData(x, y, z);
|
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
block = new CraftBlock(this, x, y, z, type, data);
|
return;
|
||||||
blockCache.put(loc, block);
|
|
||||||
} else {
|
|
||||||
block.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return block;
|
if (type == null) {
|
||||||
|
type = world.getTypeId(x, y, z);
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
data = world.getData(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
block.update(type, data.byteValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftChunk updateChunk(int x, int z) {
|
public CraftChunk updateChunk(int x, int z) {
|
||||||
|
@@ -346,9 +346,13 @@ public class CraftBlock implements Block {
|
|||||||
return world.getHandle().p(x, y, z);
|
return world.getHandle().p(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update(int type, byte data) {
|
||||||
type = world.getHandle().getTypeId(x, y, z);
|
this.type = type;
|
||||||
data = (byte)world.getHandle().getData(x, y, z);
|
this.data = data;
|
||||||
light = (byte)world.getHandle().j(x, y, z);
|
light = (byte)world.getHandle().j(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
this.update( world.getHandle().getTypeId(x, y, z), (byte)world.getHandle().getData(x, y, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user