Set<Vector3i> loadedChunks = this.cVisMan.simulatedChunks;
int minNextSimStep = Integer.MAX_VALUE;
for (Vector3i pos : loadedChunks) {
toUpdate.add(pos);
Chunk chunk = BlockSimulator.this.chunks.getChunk(pos);
minNextSimStep = Math.min(minNextSimStep, chunk.nextSimStep);
}
if (minNextSimStep == Integer.MAX_VALUE)
LogData.set("minNextSim", Integer.MAX_VALUE);
else
LogData.set("minNextSim", (minNextSimStep - engine.time) + " " + minNextSimStep);
do {
deltas.clear();
goAgain = false;
for (Vector3i pos : toUpdate) {
Chunk chunk = BlockSimulator.this.chunks.getChunk(pos);
chunk.beingUpdated = true;
simChunk(pos, deltas, step);
if (chunk.nextSimStep == -1){
goAgain = true;
}
}
for (BlockDelta delta : deltas.values()) {
BlockSimulator.this.chunks.setBlock(delta.x, delta.y, delta.z, delta.block, tmp3i, tmp2i, null);
BlockSimulator.this.chunks.setStepsToSim(delta.x, delta.y, delta.z, delta.srcStepsToSim-1, tmp3i);
if (delta.srcStepsToSim-1 > 0){
tmp3i.x = (int) Math.floor(delta.x / 32.0);
tmp3i.y = (int) Math.floor(delta.y / 16.0);
tmp3i.z = (int) Math.floor(delta.z / 32.0);
Chunk chunk = BlockSimulator.this.chunks.getChunk(tmp3i);
if (!fastified.contains(chunk)){
chunk.fastMode = true;
fastified.add(chunk);
}
}
delta.recycle();
}
} while (goAgain);
for (Vector3i pos : toUpdate) {
Chunk chunk = BlockSimulator.this.chunks.getChunk(pos);
chunk.needFirstSim = false;
chunk.beingUpdated = false;
}
for (Chunk chunk : fastified){
chunk.fastMode = false;