3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

Optimized blockCache, now only stores blocks asked for

Dieser Commit ist enthalten in:
Erik Broes 2011-01-30 20:19:56 +01:00
Ursprung da00e2e3a9
Commit 6c60b54fdf
3 geänderte Dateien mit 35 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -34,33 +34,35 @@ public class WorldServer extends World {
private final CraftWorld world; private final CraftWorld world;
private final CraftServer server; private final CraftServer server;
/**
* setData
*
* @param x
* @param y
* @param z
* @param data (actually a byte!)
*/
@Override @Override
public boolean d(int i1, int j1, int k1, int l1) { public boolean d(int x, int y, int z, int data) {
boolean result = super.d(i1, j1, k1, l1); boolean result = super.d(x, y, z, data);
if ((result) && (world != null)) world.updateBlock(i1, j1, k1); if ((result) && (world != null)) world.updateBlock(x, y, z, null, data);
return result; return result;
} }
@Override @Override
public boolean setTypeId(int i, int j, int k, int l) { public boolean setTypeId(int x, int y, int z, int type) {
boolean result = super.setTypeId(i, j, k, l); boolean result = super.setTypeId(x, y, z, type);
if ((result) && (world != null)) world.updateBlock(i, j, k); if ((result) && (world != null)) world.updateBlock(x, y, z, type, null);
return result; return result;
} }
@Override @Override
public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) { public boolean setTypeIdAndData(int x, int y, int z, int type, int data) {
boolean result = super.setTypeIdAndData(i, j, k, l, i1); boolean result = super.setTypeIdAndData(x, y, z, type, data);
if ((result) && (world != null)) world.updateBlock(i, j, k); if ((result) && (world != null)) world.updateBlock(x, y, z, type, data);
return result; return result;
} }
@Override
public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
super.setTileEntity(i, j, k, tileentity);
if (world != null) world.updateBlock(i, j, k);
}
public CraftWorld getWorld() { public CraftWorld getWorld() {
return world; return world;
} }

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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));
}
} }