fix world reset chunk repop (just noticed world gerneration is not actually seed-accurate)

This commit is contained in:
Sen 2025-07-11 13:13:17 +02:00
parent 0c6ea439eb
commit 59ecf5c6c1
Signed by: sen
GPG key ID: 3AC50A6F47D1B722

View file

@ -1256,7 +1256,7 @@ public final class WorldServer extends AWorldServer {
this.chunks.add(id, chunk); this.chunks.add(id, chunk);
this.loaded.add(chunk); this.loaded.add(chunk);
chunk.onChunkLoad(); chunk.onChunkLoad();
this.popChunk(x, z, false); this.popChunk(x, z);
} }
return chunk; return chunk;
@ -1386,7 +1386,7 @@ public final class WorldServer extends AWorldServer {
// } // }
// } // }
private void popChunk(int x, int z, boolean force) { private void popChunk(int x, int z) {
boolean n = this.chunkExists(x, z - 1); boolean n = this.chunkExists(x, z - 1);
boolean e = this.chunkExists(x + 1, z); boolean e = this.chunkExists(x + 1, z);
boolean s = this.chunkExists(x, z + 1); boolean s = this.chunkExists(x, z + 1);
@ -1398,15 +1398,6 @@ public final class WorldServer extends AWorldServer {
if(e && s && se) { if(e && s && se) {
this.populate(x, z); this.populate(x, z);
} }
else if(force) {
if(!e)
this.loadChunk(x + 1, z);
if(!s)
this.loadChunk(x, z + 1);
if(!se)
this.loadChunk(x + 1, z + 1);
this.populate(x, z);
}
if(w && s && sw) { if(w && s && sw) {
this.populate(x - 1, z); this.populate(x - 1, z);
} }
@ -1573,6 +1564,14 @@ public final class WorldServer extends AWorldServer {
this.reloadChunks(); this.reloadChunks();
} }
private void insertChunk(int x, int z) {
ChunkServer chunk = this.generate(x, z);
this.chunks.add(LongHashMap.packInt(x, z), chunk);
this.loaded.add(chunk);
chunk.onChunkLoad();
this.popChunk(x, z);
}
private void reloadChunks() { private void reloadChunks() {
for(Long v : this.dropped) { for(Long v : this.dropped) {
ChunkServer chunk = this.chunks.getValueByKey(v.longValue()); ChunkServer chunk = this.chunks.getValueByKey(v.longValue());
@ -1599,7 +1598,25 @@ public final class WorldServer extends AWorldServer {
loaded.clear(); loaded.clear();
loaded.addAll(this.loaded); loaded.addAll(this.loaded);
for(ChunkServer chunk : loaded) { for(ChunkServer chunk : loaded) {
this.popChunk(chunk.xPos, chunk.zPos, true); int x = chunk.xPos;
int z = chunk.zPos;
if(!this.chunkExists(x, z - 1))
this.insertChunk(x, z - 1);
if(!this.chunkExists(x + 1, z))
this.insertChunk(x + 1, z);
if(!this.chunkExists(x, z + 1))
this.insertChunk(x, z + 1);
if(!this.chunkExists(x - 1, z))
this.insertChunk(x - 1, z);
if(!this.chunkExists(x - 1, z - 1))
this.insertChunk(x - 1, z - 1);
if(!this.chunkExists(x + 1, z + 1))
this.insertChunk(x + 1, z + 1);
if(!this.chunkExists(x - 1, z + 1))
this.insertChunk(x - 1, z + 1);
if(!this.chunkExists(x + 1, z - 1))
this.insertChunk(x + 1, z - 1);
this.popChunk(x, z);
chunk.update(false); chunk.update(false);
} }
this.entities.removeAll(this.unloaded); this.entities.removeAll(this.unloaded);