@@ -5,22 +5,28 @@ import com.lambda.client.event.events.RenderOverlayEvent
5
5
import com.lambda.client.event.events.RenderWorldEvent
6
6
import com.lambda.client.module.Category
7
7
import com.lambda.client.plugin.api.PluginModule
8
+ import com.lambda.client.util.TickTimer
8
9
import com.lambda.client.util.graphics.ESPRenderer
9
10
import com.lambda.client.util.graphics.GlStateUtils
10
11
import com.lambda.client.util.graphics.ProjectionUtils
11
12
import com.lambda.client.util.graphics.font.FontRenderAdapter
12
13
import com.lambda.client.util.math.CoordinateConverter.asString
13
14
import com.lambda.client.util.math.VectorUtils.toVec3dCenter
14
15
import com.lambda.client.util.text.MessageSendHelper
16
+ import com.lambda.client.util.threads.defaultScope
17
+ import com.lambda.client.util.threads.runSafe
15
18
import com.lambda.client.util.threads.safeListener
19
+ import kotlinx.coroutines.launch
16
20
import net.minecraft.block.BlockNote
17
21
import net.minecraft.network.play.server.SPacketBlockAction
18
22
import net.minecraft.util.math.BlockPos
19
23
import net.minecraftforge.event.world.NoteBlockEvent
24
+ import net.minecraftforge.fml.common.gameevent.TickEvent
20
25
import org.lambda.util.Note
21
26
import org.lwjgl.opengl.GL11
22
27
import java.util.*
23
28
import java.util.concurrent.ConcurrentHashMap
29
+ import kotlin.coroutines.coroutineContext
24
30
25
31
internal object NoteESP : PluginModule(
26
32
name = " NoteESP" ,
@@ -29,14 +35,12 @@ internal object NoteESP : PluginModule(
29
35
pluginMain = MusicToolsPlugin
30
36
)
31
37
32
- // TODO: remove rendering when block is broken
33
-
34
38
{
35
39
private val page by setting(" Page" , Page .SETTINGS )
36
40
37
41
private val boxRange by setting(" Render Range for box" , 32 , 0 .. 265 , 4 , { page == Page .SETTINGS }, description = " Range for Rendering of the box" )
38
42
private val textRange by setting(" Render Range for text" , 32 , 0 .. 256 , 4 , { page == Page .SETTINGS }, description = " Range for Rendering of the text" )
39
- private val tuning by setting(" Tuning" , false , { page == Page .SETTINGS }, description = " Selectively renders only relevant layers" )
43
+ private val tuning by setting(" Tuning Mode " , false , { page == Page .SETTINGS }, description = " Selectively renders only relevant layers" )
40
44
private val tuningRange by setting(" Tuning Range" , 2 , 2 .. 6 , 1 , { tuning && page == Page .SETTINGS }, description = " Rendering for Y Level below feet" )
41
45
private val reset = setting(" Reset" , false , { page == Page .SETTINGS }, description = " Resets cached notes" )
42
46
private val debug by setting(" Debug" , false , { page == Page .SETTINGS }, description = " Debug messages in chat" )
@@ -51,8 +55,8 @@ internal object NoteESP : PluginModule(
51
55
52
56
private val cachedMusicData = ConcurrentHashMap <BlockPos , MusicData >()
53
57
private val renderer = ESPRenderer ()
54
- // private val updateTimer = TickTimer()
55
- // private const val updateDelay = 1000
58
+ private val updateTimer = TickTimer ()
59
+ private const val updateDelay = 1000L
56
60
57
61
private enum class Page {
58
62
SETTINGS , RENDER
@@ -89,6 +93,17 @@ internal object NoteESP : PluginModule(
89
93
}
90
94
}
91
95
96
+ safeListener<TickEvent .ClientTickEvent > { event ->
97
+ if (event.phase != TickEvent .Phase .START || ! updateTimer.tick(updateDelay)) return @safeListener
98
+ defaultScope.launch {
99
+ runSafe {
100
+ cachedMusicData
101
+ .filter { world.getBlockState(it.key).block !is BlockNote }
102
+ .forEach { cachedMusicData.remove(it.key) }
103
+ }
104
+ }
105
+ }
106
+
92
107
// renders box
93
108
safeListener<RenderWorldEvent > {
94
109
renderer.aFilled = if (filled) alphaFilled else 0
0 commit comments