mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
WorldRenderer: unload when client side view distance changes
This commit is contained in:
parent
ab35c3981a
commit
4f60ef2286
@ -34,7 +34,6 @@ import de.bixilon.minosoft.data.registries.fluid.FlowableFluid
|
|||||||
import de.bixilon.minosoft.data.world.World
|
import de.bixilon.minosoft.data.world.World
|
||||||
import de.bixilon.minosoft.data.world.chunk.Chunk
|
import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||||
import de.bixilon.minosoft.data.world.view.ViewDistanceChangeEvent
|
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderingStates
|
import de.bixilon.minosoft.gui.rendering.RenderingStates
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.RenderingStateChangeEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.RenderingStateChangeEvent
|
||||||
@ -277,8 +276,9 @@ class WorldRenderer(
|
|||||||
val rendering = connection.profiles.rendering
|
val rendering = connection.profiles.rendering
|
||||||
rendering.performance::fastBedrock.profileWatch(this, false, rendering) { clearChunkCache() }
|
rendering.performance::fastBedrock.profileWatch(this, false, rendering) { clearChunkCache() }
|
||||||
|
|
||||||
connection.registerEvent(CallbackEventInvoker.of<ViewDistanceChangeEvent> { event ->
|
profile::viewDistance.profileWatch(this) { viewDistance ->
|
||||||
if (event.viewDistance < this.previousViewDistance) {
|
val distance = maxOf(viewDistance, profile.simulationDistance)
|
||||||
|
if (distance < this.previousViewDistance) {
|
||||||
// Unload all chunks(-sections) that are out of view distance
|
// Unload all chunks(-sections) that are out of view distance
|
||||||
culledQueueLock.lock()
|
culledQueueLock.lock()
|
||||||
queueLock.lock()
|
queueLock.lock()
|
||||||
@ -333,8 +333,8 @@ class WorldRenderer(
|
|||||||
prepareWorld()
|
prepareWorld()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.previousViewDistance = event.viewDistance
|
this.previousViewDistance = distance
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun silentlyClearChunkCache() {
|
fun silentlyClearChunkCache() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user