diff --git a/src/main/java/cn/nukkit/level/Level.java b/src/main/java/cn/nukkit/level/Level.java index 497d0dd5d2b..79c667e9bd1 100644 --- a/src/main/java/cn/nukkit/level/Level.java +++ b/src/main/java/cn/nukkit/level/Level.java @@ -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() { diff --git a/src/main/java/cn/nukkit/level/format/LevelProvider.java b/src/main/java/cn/nukkit/level/format/LevelProvider.java index df7da3c6180..70a14793c73 100644 --- a/src/main/java/cn/nukkit/level/format/LevelProvider.java +++ b/src/main/java/cn/nukkit/level/format/LevelProvider.java @@ -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); diff --git a/src/main/java/cn/nukkit/level/format/anvil/Anvil.java b/src/main/java/cn/nukkit/level/format/anvil/Anvil.java index c5bab374490..68cef6d0a30 100644 --- a/src/main/java/cn/nukkit/level/format/anvil/Anvil.java +++ b/src/main/java/cn/nukkit/level/format/anvil/Anvil.java @@ -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); } diff --git a/src/main/java/cn/nukkit/level/format/leveldb/LevelDB.java b/src/main/java/cn/nukkit/level/format/leveldb/LevelDB.java index 868671ea210..bbb93d22bbc 100644 --- a/src/main/java/cn/nukkit/level/format/leveldb/LevelDB.java +++ b/src/main/java/cn/nukkit/level/format/leveldb/LevelDB.java @@ -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); diff --git a/src/main/java/cn/nukkit/level/format/mcregion/McRegion.java b/src/main/java/cn/nukkit/level/format/mcregion/McRegion.java index b38ab2de473..850425d5742 100644 --- a/src/main/java/cn/nukkit/level/format/mcregion/McRegion.java +++ b/src/main/java/cn/nukkit/level/format/mcregion/McRegion.java @@ -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); }