Skip to content

Commit 1780dc0

Browse files
committed
Changed to better fitting packet
1 parent bbb7649 commit 1780dc0

1 file changed

Lines changed: 7 additions & 23 deletions

File tree

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.lambda.client.util.math.VectorUtils.toVec3dCenter
1414
import com.lambda.client.util.text.MessageSendHelper
1515
import com.lambda.event.listener.listener
1616
import net.minecraft.init.SoundEvents
17+
import net.minecraft.network.play.server.SPacketBlockAction
1718
import net.minecraft.network.play.server.SPacketSoundEffect
1819
import net.minecraft.util.SoundEvent
1920
import net.minecraft.util.math.BlockPos
@@ -51,17 +52,16 @@ internal object NoteESP: PluginModule(
5152
}
5253

5354
listener<PacketEvent.Receive> { event ->
54-
if (event.packet is SPacketSoundEffect) {
55-
val packet = (event.packet as SPacketSoundEffect)
55+
if (event.packet is SPacketBlockAction) {
56+
val packet = (event.packet as SPacketBlockAction)
5657

57-
val instrument = getInstrument(packet.sound) ?: return@listener
58-
val pos = BlockPos(packet.x, packet.y, packet.z)
59-
val note = Note.values()[(log2(packet.pitch.toDouble()) * 12.0).roundToInt() + 12]
58+
val instrument = NoteBlockEvent.Instrument.values()[packet.data1]
59+
val note = Note.values()[packet.data2]
6060

61-
cachedNotes[pos] = note
61+
cachedNotes[packet.blockPosition] = note
6262

6363
if (debug) {
64-
MessageSendHelper.sendChatMessage("Instrument: ${instrument.name} Pos: (${packet.x},${packet.y},${packet.z}) Pitch: ${note.name}")
64+
MessageSendHelper.sendChatMessage("Instrument: ${instrument.name} Pos: (${packet.blockPosition.asString()}) Pitch: ${note.name}")
6565
}
6666
}
6767
}
@@ -96,20 +96,4 @@ internal object NoteESP: PluginModule(
9696
}
9797
}
9898
}
99-
100-
private fun getInstrument(soundEvent: SoundEvent): NoteBlockEvent.Instrument? {
101-
return when (soundEvent) {
102-
SoundEvents.BLOCK_NOTE_HARP -> NoteBlockEvent.Instrument.PIANO
103-
SoundEvents.BLOCK_NOTE_BASEDRUM -> NoteBlockEvent.Instrument.BASSDRUM
104-
SoundEvents.BLOCK_NOTE_SNARE -> NoteBlockEvent.Instrument.SNARE
105-
SoundEvents.BLOCK_NOTE_HAT -> NoteBlockEvent.Instrument.CLICKS
106-
SoundEvents.BLOCK_NOTE_BASS -> NoteBlockEvent.Instrument.BASSGUITAR
107-
SoundEvents.BLOCK_NOTE_FLUTE -> NoteBlockEvent.Instrument.FLUTE
108-
SoundEvents.BLOCK_NOTE_BELL -> NoteBlockEvent.Instrument.BELL
109-
SoundEvents.BLOCK_NOTE_GUITAR -> NoteBlockEvent.Instrument.GUITAR
110-
SoundEvents.BLOCK_NOTE_CHIME -> NoteBlockEvent.Instrument.CHIME
111-
SoundEvents.BLOCK_NOTE_XYLOPHONE -> NoteBlockEvent.Instrument.XYLOPHONE
112-
else -> null
113-
}
114-
}
11599
}

0 commit comments

Comments
 (0)