@@ -7,8 +7,6 @@ import com.lambda.event.listener.SafeListener.Companion.concurrentListener
77import com.lambda.event.listener.SafeListener.Companion.listener
88import com.lambda.module.modules.client.RenderSettings
99import com.lambda.threading.runGameBlocking
10- import com.mojang.blaze3d.systems.RenderSystem.recordRenderCall
11- import kotlinx.coroutines.*
1210import net.minecraft.util.math.BlockPos
1311import net.minecraft.util.math.ChunkPos
1412import 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