Skip to content

Commit

Permalink
Fix regenerateChunk method
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Feb 25, 2024
1 parent f174d42 commit 740e298
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/cn/nukkit/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -4266,11 +4266,14 @@ public void generateChunk(int x, int z, boolean force) {
}

public void regenerateChunk(int x, int z) {
this.unloadChunk(x, z, false);
this.unloadChunk(x, z, false, false);

this.cancelUnloadChunkRequest(x, z);

this.generateChunk(x, z);
BaseFullChunk chunk = provider.getEmptyChunk(x, z);
provider.setChunk(x, z, chunk);

this.generateChunk(x, z, true);
}

public void doChunkGarbageCollection() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cn/nukkit/level/format/LevelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public interface LevelProvider {

BaseFullChunk getChunk(int X, int Z, boolean create);

BaseFullChunk getEmptyChunk(int x, int z);

void saveChunks();

void saveChunk(int X, int Z);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/nukkit/level/format/anvil/Anvil.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public static void generate(String path, String name, LevelCreationOptions optio
NBTIO.writeGZIPCompressed(new CompoundTag().putCompound("Data", levelData), Files.newOutputStream(Paths.get(path, "level.dat")), ByteOrder.BIG_ENDIAN);
}

@Override
public Chunk getEmptyChunk(int chunkX, int chunkZ) {
return Chunk.getEmptyChunk(chunkX, chunkZ, this);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/level/format/leveldb/LevelDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ public LevelProviderHandle getHandle() {
return LevelProviderManager.LEVELDB;
}

@Override
public LevelDbChunk getEmptyChunk(int chunkX, int chunkZ) {
return LevelDbChunk.getEmptyChunk(chunkX, chunkZ, this);
}

@Override
public AsyncTask requestChunkTask(int chunkX, int chunkZ) {
LevelDbChunk chunk = this.getChunk(chunkX, chunkZ, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public BaseFullChunk loadChunk(long index, int chunkX, int chunkZ, boolean creat
return chunk;
}

@Override
public Chunk getEmptyChunk(int chunkX, int chunkZ) {
return Chunk.getEmptyChunk(chunkX, chunkZ, this);
}
Expand Down

0 comments on commit 740e298

Please sign in to comment.