@@ -4,24 +4,33 @@ import com.lambda.client.event.events.PacketEvent
44import com.lambda.client.event.events.RenderOverlayEvent
55import com.lambda.client.event.events.RenderWorldEvent
66import com.lambda.client.module.Category
7+ import com.lambda.client.module.modules.render.Search
8+ import com.lambda.client.module.modules.render.Search.setting
79import com.lambda.client.plugin.api.PluginModule
810import com.lambda.client.util.graphics.ESPRenderer
911import com.lambda.client.util.graphics.GlStateUtils
1012import com.lambda.client.util.graphics.ProjectionUtils
1113import com.lambda.client.util.graphics.font.FontRenderAdapter
1214import com.lambda.client.util.math.CoordinateConverter.asString
15+ import com.lambda.client.util.math.VectorUtils.distanceTo
1316import com.lambda.client.util.math.VectorUtils.toVec3dCenter
1417import com.lambda.client.util.text.MessageSendHelper
1518import com.lambda.event.listener.listener
19+ import net.minecraft.block.state.IBlockState
20+ import net.minecraft.init.Blocks
1621import net.minecraft.init.SoundEvents
1722import net.minecraft.network.play.server.SPacketBlockAction
1823import net.minecraft.network.play.server.SPacketSoundEffect
1924import net.minecraft.util.SoundEvent
2025import net.minecraft.util.math.BlockPos
26+ import net.minecraft.util.math.Vec3d
27+ import net.minecraft.world.chunk.Chunk
2128import net.minecraftforge.event.world.NoteBlockEvent
2229import org.lambda.util.Note
2330import org.lwjgl.opengl.GL11
31+ import java.awt.Color
2432import java.util.concurrent.ConcurrentHashMap
33+ import javax.sound.midi.Instrument
2534import kotlin.math.log2
2635import kotlin.math.roundToInt
2736
@@ -30,27 +39,42 @@ internal object NoteESP: PluginModule(
3039 category = Category .RENDER ,
3140 description = " Shows note block pitch" ,
3241 pluginMain = MusicToolsPlugin
33- ) {
42+ )
43+
44+ // TODO: no listener for non note blocks > i already did that? i dont see where
45+ // TODO: render only for own y to own y - 2 > vague ideas, but i have no idea how
46+ // TODO: range for rendering > found something in the search module but have no idea how to adapt this
47+ // TODO: 1.12.2 color mode of the rendering > no idea how to tell him to use the default colors
48+ // TODO: add instrument to rendering > no idea how. do i need another concurrenthashmap for that? i at least managed to render a second line on the block
49+ // TODO: remove rendering when block is broken > no idea how to check regularly if the block is still there
50+
51+ {
3452 private val filled by setting(" Filled" , true , description = " Renders surfaces" )
3553 private val outline by setting(" Outline" , true , description = " Renders outline" )
3654 private val alphaFilled by setting(" Alpha Filled" , 26 , 0 .. 255 , 1 , { filled }, description = " Alpha for surfaces" )
3755 private val alphaOutline by setting(" Alpha Outline" , 26 , 0 .. 255 , 1 , { outline }, description = " Alpha for outline" )
3856 private val thickness by setting(" Outline Thickness" , 2f , .25f .. 4f , .25f , { outline })
3957 private val textScale by setting(" Text Scale" , 1f , .0f .. 4f , .25f )
58+ private val colorScheme by setting(" Color Scheme" , ColorScheme .DEFAULT , description = " Changes Color Scheme" )
59+ private val range by setting(" Search Range" , 128 , 0 .. 256 , 8 , description = " Range for Rendering" )
4060 private val reset = setting(" Reset" , false , description = " Resets cached notes" )
4161 private val debug by setting(" Debug" , false , description = " Debug messages in chat" )
4262
4363 private val cachedNotes = ConcurrentHashMap <BlockPos , Note >()
4464 private val renderer = ESPRenderer ()
4565
66+ enum class ColorScheme {
67+ DEFAULT , RAINBOW
68+ }
69+ // reset button
4670 init {
4771 reset.consumers.add { _, it ->
4872 if (it) {
4973 cachedNotes.clear()
5074 }
5175 false
5276 }
53-
77+ // listens to played note block
5478 listener<PacketEvent .Receive > { event ->
5579 if (event.packet is SPacketBlockAction ) {
5680 val packet = (event.packet as SPacketBlockAction )
@@ -66,18 +90,25 @@ internal object NoteESP: PluginModule(
6690 }
6791 }
6892
93+ // renders box
6994 listener<RenderWorldEvent > {
7095 renderer.aFilled = if (filled) alphaFilled else 0
7196 renderer.aOutline = if (outline) alphaOutline else 0
7297 renderer.thickness = thickness
7398
7499 cachedNotes.forEach {
75- renderer.add(it.key, it.value.color)
100+ // when(colorScheme){
101+ // ColorScheme.DEFAULT -> {
102+ // renderer.add(it.key, it.value.default)
103+ // }
104+ // ColorScheme.RAINBOW -> {
105+ renderer.add(it.key, it.value.rainbow)
106+ // }
107+ // }
76108 }
77-
78109 renderer.render(true )
79110 }
80-
111+ // renders text overlay
81112 listener<RenderOverlayEvent > {
82113 GlStateUtils .rescaleActual()
83114
@@ -89,8 +120,10 @@ internal object NoteESP: PluginModule(
89120 GL11 .glTranslated(screenPos.x, screenPos.y, 0.0 )
90121 GL11 .glScalef(textScale * 2f , textScale * 2f , 1f )
91122
92- val center = FontRenderAdapter .getStringWidth(it.value.ordinal.toString()) / - 2f
93- FontRenderAdapter .drawString(it.value.ordinal.toString(), center, 0f , color = it.value.color)
123+ val centerValue = FontRenderAdapter .getStringWidth(it.value.ordinal.toString()) / - 2f
124+ val centerKey = FontRenderAdapter .getStringWidth(it.key.toString()) / - 2f
125+ FontRenderAdapter .drawString(it.value.ordinal.toString(), centerValue, 0f , color = it.value.rainbow)
126+ FontRenderAdapter .drawString(it.key.toString(), centerKey, + 10f , color = it.value.rainbow)
94127
95128 GL11 .glPopMatrix()
96129 }
0 commit comments