rendering: handle unload chunk packet

This commit is contained in:
Bixilon 2021-02-12 20:58:41 +01:00
parent edcc288898
commit 2ce1f233af
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 12 additions and 0 deletions

View File

@ -149,4 +149,15 @@ class ChunkRenderer(private val connection: Connection, private val world: World
}
}
}
fun unloadChunk(location: ChunkLocation) {
renderWindow.renderQueue.add {
chunkSectionsToDraw[location]?.let {
for ((_, mesh) in it) {
mesh.unload()
}
chunkSectionsToDraw.remove(location)
}
}
}
}

View File

@ -31,6 +31,7 @@ public class PacketUnloadChunk extends ClientboundPacket {
@Override
public void handle(Connection connection) {
connection.getPlayer().getWorld().unloadChunk(getLocation());
connection.getRenderer().getRenderWindow().getChunkRenderer().unloadChunk(this.location);
}
@Override