Skip to content

Commit 4514c4d

Browse files
committed
Feature to remove outdated music data
1 parent b51bf60 commit 4514c4d

File tree

5 files changed

+20
-127
lines changed

5 files changed

+20
-127
lines changed

src/main/kotlin/org/lambda/ExampleCommand.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/kotlin/org/lambda/ExampleLabelHud.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/kotlin/org/lambda/ExampleModule.kt

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/main/kotlin/org/lambda/MusicToolsPlugin.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ internal object MusicToolsPlugin : Plugin() {
77
override fun onLoad() {
88
// Load any modules, commands, or HUD elements here
99
modules.add(NoteESP)
10-
commands.add(ExampleCommand)
11-
hudElements.add(ExampleLabelHud)
1210
}
1311

1412
override fun onUnload() {

src/main/kotlin/org/lambda/NoteESP.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@ import com.lambda.client.event.events.RenderOverlayEvent
55
import com.lambda.client.event.events.RenderWorldEvent
66
import com.lambda.client.module.Category
77
import com.lambda.client.plugin.api.PluginModule
8+
import com.lambda.client.util.TickTimer
89
import com.lambda.client.util.graphics.ESPRenderer
910
import com.lambda.client.util.graphics.GlStateUtils
1011
import com.lambda.client.util.graphics.ProjectionUtils
1112
import com.lambda.client.util.graphics.font.FontRenderAdapter
1213
import com.lambda.client.util.math.CoordinateConverter.asString
1314
import com.lambda.client.util.math.VectorUtils.toVec3dCenter
1415
import com.lambda.client.util.text.MessageSendHelper
16+
import com.lambda.client.util.threads.defaultScope
17+
import com.lambda.client.util.threads.runSafe
1518
import com.lambda.client.util.threads.safeListener
19+
import kotlinx.coroutines.launch
1620
import net.minecraft.block.BlockNote
1721
import net.minecraft.network.play.server.SPacketBlockAction
1822
import net.minecraft.util.math.BlockPos
1923
import net.minecraftforge.event.world.NoteBlockEvent
24+
import net.minecraftforge.fml.common.gameevent.TickEvent
2025
import org.lambda.util.Note
2126
import org.lwjgl.opengl.GL11
2227
import java.util.*
2328
import java.util.concurrent.ConcurrentHashMap
29+
import kotlin.coroutines.coroutineContext
2430

2531
internal object NoteESP : PluginModule(
2632
name = "NoteESP",
@@ -29,14 +35,12 @@ internal object NoteESP : PluginModule(
2935
pluginMain = MusicToolsPlugin
3036
)
3137

32-
//TODO: remove rendering when block is broken
33-
3438
{
3539
private val page by setting("Page", Page.SETTINGS)
3640

3741
private val boxRange by setting("Render Range for box", 32, 0..265, 4, { page == Page.SETTINGS }, description = "Range for Rendering of the box")
3842
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")
4044
private val tuningRange by setting("Tuning Range", 2, 2..6, 1, { tuning && page == Page.SETTINGS }, description = "Rendering for Y Level below feet")
4145
private val reset = setting("Reset", false, { page == Page.SETTINGS }, description = "Resets cached notes")
4246
private val debug by setting("Debug", false, { page == Page.SETTINGS }, description = "Debug messages in chat")
@@ -51,8 +55,8 @@ internal object NoteESP : PluginModule(
5155

5256
private val cachedMusicData = ConcurrentHashMap<BlockPos, MusicData>()
5357
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
5660

5761
private enum class Page {
5862
SETTINGS, RENDER
@@ -89,6 +93,17 @@ internal object NoteESP : PluginModule(
8993
}
9094
}
9195

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+
92107
//renders box
93108
safeListener<RenderWorldEvent> {
94109
renderer.aFilled = if (filled) alphaFilled else 0

0 commit comments

Comments
 (0)