Skip to content

Commit bdf03d4

Browse files
committed
Small changes and preparations for upcoming functions
1 parent 1780dc0 commit bdf03d4

2 files changed

Lines changed: 70 additions & 9 deletions

File tree

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

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ import com.lambda.client.event.events.PacketEvent
44
import com.lambda.client.event.events.RenderOverlayEvent
55
import com.lambda.client.event.events.RenderWorldEvent
66
import com.lambda.client.module.Category
7+
import com.lambda.client.module.modules.render.Search
8+
import com.lambda.client.module.modules.render.Search.setting
79
import com.lambda.client.plugin.api.PluginModule
810
import com.lambda.client.util.graphics.ESPRenderer
911
import com.lambda.client.util.graphics.GlStateUtils
1012
import com.lambda.client.util.graphics.ProjectionUtils
1113
import com.lambda.client.util.graphics.font.FontRenderAdapter
1214
import com.lambda.client.util.math.CoordinateConverter.asString
15+
import com.lambda.client.util.math.VectorUtils.distanceTo
1316
import com.lambda.client.util.math.VectorUtils.toVec3dCenter
1417
import com.lambda.client.util.text.MessageSendHelper
1518
import com.lambda.event.listener.listener
19+
import net.minecraft.block.state.IBlockState
20+
import net.minecraft.init.Blocks
1621
import net.minecraft.init.SoundEvents
1722
import net.minecraft.network.play.server.SPacketBlockAction
1823
import net.minecraft.network.play.server.SPacketSoundEffect
1924
import net.minecraft.util.SoundEvent
2025
import net.minecraft.util.math.BlockPos
26+
import net.minecraft.util.math.Vec3d
27+
import net.minecraft.world.chunk.Chunk
2128
import net.minecraftforge.event.world.NoteBlockEvent
2229
import org.lambda.util.Note
2330
import org.lwjgl.opengl.GL11
31+
import java.awt.Color
2432
import java.util.concurrent.ConcurrentHashMap
33+
import javax.sound.midi.Instrument
2534
import kotlin.math.log2
2635
import 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
}

src/main/kotlin/org/lambda/util/Note.kt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.lambda.util
22

33
import com.lambda.client.util.color.ColorHolder
44

5-
enum class Note(val color: ColorHolder) {
5+
enum class Note(val rainbow: ColorHolder) {
66
F_SHARP_LOW(ColorHolder(119, 215, 0)),
77
G_LOW(ColorHolder(149, 192, 0)),
88
G_SHARP_LOW(ColorHolder(178, 165, 0)),
@@ -28,4 +28,32 @@ enum class Note(val color: ColorHolder) {
2828
E_HIGH(ColorHolder(31, 252, 0)),
2929
F_HIGH(ColorHolder(89, 232, 0)),
3030
F_SHARP_SUPER_HIGH(ColorHolder(148, 193, 0))
31-
}
31+
}
32+
33+
//enum class Note(val default: ColorHolder) {
34+
// F_SHARP_LOW(ColorHolder(85, 221, 192)),
35+
// G_LOW(ColorHolder(126, 196, 177)),
36+
// G_SHARP_LOW(ColorHolder(164, 164, 171)),
37+
// A_LOW(ColorHolder(196, 126, 177)),
38+
// A_SHARP_LOW(ColorHolder(221, 85, 192)),
39+
// B_LOW(ColorHolder(237, 44, 218)),
40+
// C_LOW(ColorHolder(243, 6, 6)),
41+
// C_SHARP_LOW(ColorHolder(237, 218, 44)),
42+
// D_LOW(ColorHolder(221, 192, 85)),
43+
// D_SHARP_LOW(ColorHolder(196, 177, 126)),
44+
// E_LOW(ColorHolder(164, 171, 164)),
45+
// F_LOW(ColorHolder(126, 177, 196)),
46+
// F_SHARP_HIGH(ColorHolder(85, 192, 221)),
47+
// G_HIGH(ColorHolder(44, 218, 237)),
48+
// G_SHARP_HIGH(ColorHolder(6, 6, 243)),
49+
// A_HIGH(ColorHolder(218, 44, 237)),
50+
// A_SHARP_HIGH(ColorHolder(192, 85, 221)),
51+
// B_HIGH(ColorHolder(177, 126, 196)),
52+
// C_HIGH(ColorHolder(171, 164, 164)),
53+
// C_SHARP_HIGH(ColorHolder(177, 196, 126)),
54+
// D_HIGH(ColorHolder(192, 221, 85)),
55+
// D_SHARP_HIGH(ColorHolder(218, 237, 44)),
56+
// E_HIGH(ColorHolder(6, 243, 6)),
57+
// F_HIGH(ColorHolder(44, 237, 218)),
58+
// F_SHARP_SUPER_HIGH(ColorHolder(85, 221, 192))
59+
//}

0 commit comments

Comments
 (0)