Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean unloadQueuedChunks() {
- // NOTE: the return value is completely ignored
- if (this.worldServer.getDisableLevelSaving()) {
- return false;
- }
- final int maxColumnsToUnload = 100;
- final int maxCubesToUnload = 100*16;
- // unload cubes
- for (int i = 0; i < maxCubesToUnload && !this.cubesToUnload.isEmpty(); i++) {
- long cubeAddress = this.cubesToUnload.poll();
- long columnAddress = cubeToColumn(cubeAddress);
- // get the cube
- Column column = this.loadedColumns.get(columnAddress);
- if (column == null) {
- // already unloaded
- continue;
- }
- // unload the cube
- int cubeY = getY(cubeAddress);
- unloadAndSaveCube(column, cubeY);
- // unload column if it's empty or contains only force-loaded cubes
- boolean canUnload = true;
- for (Cube cube : column.getAllCubes()) {
- if (canQueueUnloadColumnForCube(cube)) {
- canUnload = false;
- break;
- }
- }
- if (canUnload) {
- //breaks here
- for (Cube cube : column.getAllCubes()) {
- unloadAndSaveCube(column, cube.getY());
- }
- assert column.getAllCubes().isEmpty();
- this.columnsToUnload.add(column.getChunkCoordIntPair());
- }
- }
- Set<ChunkPos> toReadd = new HashSet<>();
- for (int i = 0; i < maxColumnsToUnload && !columnsToUnload.isEmpty(); ) {
- ChunkPos pos = columnsToUnload.poll();
- Column column = this.getColumn(pos.chunkXPos, pos.chunkZPos);
- if (column == null) {
- continue;
- }
- if (!column.getAllCubes().isEmpty()) {
- toReadd.add(pos);
- continue;
- }
- i++;
- column.onChunkUnload();
- this.loadedColumns.remove(column.getAddress());
- this.cubeIO.saveColumn(column);
- }
- columnsToUnload.addAll(toReadd);
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement