From 0bc7a7bbf6d698973d452a54dc7e13271bce9c2c Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Fri, 8 Dec 2023 07:41:07 +0100 Subject: [PATCH] biome cache resetting --- .../profiles/rendering/performance/PerformanceC.kt | 1 - .../de/bixilon/minosoft/data/world/biome/WorldBiomes.kt | 9 ++++++++- .../terminal/commands/connection/DebugCommand.kt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/performance/PerformanceC.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/performance/PerformanceC.kt index b9d643942..7885ab374 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/performance/PerformanceC.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/performance/PerformanceC.kt @@ -29,7 +29,6 @@ class PerformanceC(profile: RenderingProfile) { * Biomes may not match anymore. * If true, chunk receiving is way faster. * Only affects 19w36+ (~1.14.4) - * ToDo: Requires rejoin to apply */ var fastBiomeNoise by BooleanDelegate(profile, false) diff --git a/src/main/java/de/bixilon/minosoft/data/world/biome/WorldBiomes.kt b/src/main/java/de/bixilon/minosoft/data/world/biome/WorldBiomes.kt index a9b6a2922..974250ff4 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/biome/WorldBiomes.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/biome/WorldBiomes.kt @@ -67,6 +67,13 @@ class WorldBiomes(val world: World) : BiomeAccessor { fun resetCache() { - // TODO + world.lock.lock() + for ((_, chunk) in world.chunks.chunks.unsafe) { + for (section in chunk.sections) { + if (section == null) continue + section.biomes.clear() + } + } + world.lock.unlock() } } diff --git a/src/main/java/de/bixilon/minosoft/terminal/commands/connection/DebugCommand.kt b/src/main/java/de/bixilon/minosoft/terminal/commands/connection/DebugCommand.kt index 86c4d4679..b1cc56ebe 100644 --- a/src/main/java/de/bixilon/minosoft/terminal/commands/connection/DebugCommand.kt +++ b/src/main/java/de/bixilon/minosoft/terminal/commands/connection/DebugCommand.kt @@ -25,6 +25,7 @@ object DebugCommand : ConnectionCommand { .addChild(LiteralNode("network").addChild( LiteralNode("detach", executor = { it.connection.network.detach(); it.connection.util.sendDebugMessage("Now you are alone on the wire...") }), )) + .addChild(LiteralNode("cache").addChild(LiteralNode("biome", executor = { it.connection.world.biomes.resetCache(); it.connection.util.sendDebugMessage("Biome cache cleared!") }))) private fun CommandStack.fly() {