Skip to content

Commit 974d9cd

Browse files
committed
ChillyWeelly
1 parent 4931fa2 commit 974d9cd

File tree

1 file changed

+5
-18
lines changed
  • common/src/main/kotlin/com/lambda/graphics/renderer/esp

1 file changed

+5
-18
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/esp/ChunkedESP.kt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import com.lambda.event.listener.SafeListener.Companion.concurrentListener
77
import com.lambda.event.listener.SafeListener.Companion.listener
88
import com.lambda.module.modules.client.RenderSettings
99
import com.lambda.threading.runGameBlocking
10-
import com.mojang.blaze3d.systems.RenderSystem.recordRenderCall
11-
import kotlinx.coroutines.*
1210
import net.minecraft.util.math.BlockPos
1311
import net.minecraft.util.math.ChunkPos
1412
import net.minecraft.world.BlockView
@@ -39,7 +37,7 @@ class ChunkedESP private constructor(
3937
init {
4038
owner.concurrentListener<WorldEvent.BlockUpdate> { event ->
4139
world.getWorldChunk(event.pos).renderer.apply {
42-
markOutdated()
40+
queueRebuild()
4341
notifyNeighbors()
4442
}
4543
}
@@ -55,7 +53,7 @@ class ChunkedESP private constructor(
5553
owner.concurrentListener<TickEvent.Pre> {
5654
if (++ticks % RenderSettings.updateFrequency == 0) {
5755
rendererMap.values
58-
.filter { it.outdated && it.neighborsLoaded }
56+
.filter { it.neighborsLoaded }
5957
.forEach { it.rebuild() }
6058
ticks = 0
6159
}
@@ -95,13 +93,13 @@ class ChunkedESP private constructor(
9593

9694
fun ChunkPos.isLoaded() = chunk.world.chunkManager.isChunkLoaded(x, z)
9795

98-
fun markOutdated() {
99-
outdated = true
96+
fun queueRebuild() {
97+
owner.rebuildPool.add(this)
10098
}
10199

102100
fun notifyNeighbors() {
103101
neighbors.forEach {
104-
owner.rendererMap[it]?.markOutdated()
102+
owner.rendererMap[it]?.queueRebuild()
105103
}
106104
}
107105

@@ -133,17 +131,6 @@ class ChunkedESP private constructor(
133131
}
134132
}
135133

136-
private suspend fun <R: Any> runOnMainThreadAndWait(block: () -> R): R {
137-
var result: R? = null
138-
139-
recordRenderCall {
140-
result = block()
141-
}
142-
143-
while (result == null) delay(1)
144-
return result as R
145-
}
146-
147134
private fun draw(renderer: EspRenderer, x: Int, y: Int, z: Int) {
148135
if (!owner.update(chunk, blockPos)) return false
149136
}

0 commit comments

Comments
 (0)