Skip to content

Commit 5773979

Browse files
Improved packet logging for entity movement and player list (#444)
* added option to ignore player position * added logging of entityID for entity moving packets * added SPacketPlayerListItem to packet logger * added SPacketSpawnPlayer to packet logger
1 parent 272172a commit 5773979

File tree

5 files changed

+147
-38
lines changed

5 files changed

+147
-38
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.lambda.mixin.accessor.network;
2+
3+
import net.minecraft.network.play.server.SPacketEntity;
4+
import net.minecraft.network.play.server.SPacketEntityVelocity;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(SPacketEntity.class)
9+
public interface AccessorSPacketEntity {
10+
11+
@Accessor("entityId")
12+
int getEntityId();
13+
14+
@Accessor("entityId")
15+
void setEntityId(int value);
16+
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lambda.mixin.accessor.network;
2+
3+
import net.minecraft.network.play.server.SPacketEntityHeadLook;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.gen.Accessor;
6+
7+
@Mixin(SPacketEntityHeadLook.class)
8+
public interface AccessorSPacketEntityHeadLook {
9+
10+
@Accessor("entityId")
11+
int getEntityId();
12+
13+
@Accessor("entityId")
14+
void setEntityId(int value);
15+
16+
}

src/main/kotlin/com/lambda/client/mixin/extension/Network.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import net.minecraft.network.play.client.CPacketChatMessage
55
import net.minecraft.network.play.client.CPacketCloseWindow
66
import net.minecraft.network.play.client.CPacketPlayer
77
import net.minecraft.network.play.client.CPacketUseEntity
8-
import net.minecraft.network.play.server.SPacketChat
9-
import net.minecraft.network.play.server.SPacketEntityVelocity
10-
import net.minecraft.network.play.server.SPacketExplosion
11-
import net.minecraft.network.play.server.SPacketPlayerPosLook
8+
import net.minecraft.network.play.server.*
129
import net.minecraft.util.text.ITextComponent
1310

1411
var CPacketChatMessage.chatMessage: String
@@ -113,4 +110,16 @@ var SPacketPlayerPosLook.playerPosLookPitch: Float
113110
get() = this.pitch
114111
set(value) {
115112
(this as AccessorSPacketPosLook).setPitch(value)
113+
}
114+
115+
var SPacketEntity.entityId: Int
116+
get() = (this as AccessorSPacketEntity).entityId
117+
set(value) {
118+
(this as AccessorSPacketEntity).entityId = value
119+
}
120+
121+
var SPacketEntityHeadLook.entityHeadLookEntityId: Int
122+
get() = (this as AccessorSPacketEntityHeadLook).entityId
123+
set(value) {
124+
(this as AccessorSPacketEntityHeadLook).entityId = value
116125
}

src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt

Lines changed: 99 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.lambda.client.event.listener.listener
88
import com.lambda.client.mixin.extension.*
99
import com.lambda.client.module.Category
1010
import com.lambda.client.module.Module
11-
import com.lambda.client.module.modules.misc.MapDownloader.setting
1211
import com.lambda.client.util.FolderUtils
1312
import com.lambda.client.util.TickTimer
1413
import com.lambda.client.util.TimeUnit
@@ -43,6 +42,8 @@ object PacketLogger : Module(
4342
private val ignoreUnknown by setting("Ignore Unknown Packets", false, description = "Ignore packets that aren't explicitly handled.")
4443
private val ignoreChat by setting("Ignore Chat", true, description = "Ignore chat packets.")
4544
private val ignoreCancelled by setting("Ignore Cancelled", true, description = "Ignore cancelled packets.")
45+
private val ignorePlayerPosition by setting("Ignore Player Position", false, description = "Ignore sent position & rotation packets.")
46+
private val ignoreTimeUpdates by setting("Ignore Time Updates", false, description = "Ignore time update packets.")
4647
private val openLogFolder by setting("Open Log Folder...", false, consumer = { _, _ ->
4748
FolderUtils.openFolder(FolderUtils.packetLogFolder)
4849
true
@@ -308,8 +309,39 @@ object PacketLogger : Module(
308309
"isSoundServerwide" to packet.isSoundServerwide
309310
}
310311
}
312+
is SPacketEntity.S15PacketEntityRelMove -> {
313+
logServer(packet) {
314+
"entityId" to packet.entityId
315+
"x" to packet.x
316+
"y" to packet.y
317+
"z" to packet.z
318+
"onGround" to packet.onGround
319+
}
320+
}
321+
is SPacketEntity.S16PacketEntityLook -> {
322+
logServer(packet) {
323+
"entityId" to packet.entityId
324+
"yaw" to packet.yaw
325+
"pitch" to packet.pitch
326+
"isRotating" to packet.isRotating
327+
"onGround" to packet.onGround
328+
}
329+
}
330+
is SPacketEntity.S17PacketEntityLookMove -> {
331+
logServer(packet) {
332+
"entityId" to packet.entityId
333+
"x" to packet.x
334+
"y" to packet.y
335+
"z" to packet.z
336+
"yaw" to packet.yaw
337+
"pitch" to packet.pitch
338+
"isRotating" to packet.isRotating
339+
"onGround" to packet.onGround
340+
}
341+
}
311342
is SPacketEntity -> {
312343
logServer(packet) {
344+
"entityId" to packet.entityId
313345
"x" to packet.x
314346
"y" to packet.y
315347
"z" to packet.z
@@ -344,6 +376,7 @@ object PacketLogger : Module(
344376
}
345377
is SPacketEntityHeadLook -> {
346378
logServer(packet) {
379+
"entityId" to packet.entityHeadLookEntityId
347380
"yaw" to packet.yaw
348381
}
349382
}
@@ -378,12 +411,12 @@ object PacketLogger : Module(
378411
}
379412
is SPacketEntityTeleport -> {
380413
logServer(packet) {
414+
"entityID" to packet.entityId
381415
"x" to packet.x
382416
"y" to packet.y
383417
"z" to packet.z
384418
"yaw" to packet.yaw
385419
"pitch" to packet.pitch
386-
"entityID" to packet.entityId
387420
}
388421
}
389422
is SPacketEntityVelocity -> {
@@ -517,6 +550,28 @@ object PacketLogger : Module(
517550
}
518551
}
519552
}
553+
is SPacketPlayerListItem -> {
554+
logServer(packet) {
555+
"action" to packet.action.name
556+
"entries" to buildString {
557+
for (entry in packet.entries) {
558+
append("> displayName: ")
559+
append(entry.displayName)
560+
append(" gameMode: ")
561+
append(entry.gameMode?.name)
562+
append(" ping: ")
563+
append(entry.ping)
564+
append(" profile.id: ")
565+
append(entry.profile?.id)
566+
append(" profile.name: ")
567+
append(entry.profile?.name)
568+
append(" profile.properties: ")
569+
append(entry.profile?.properties)
570+
append(' ')
571+
}
572+
}
573+
}
574+
}
520575
is SPacketSoundEffect -> {
521576
logServer(packet) {
522577
"sound" to packet.sound.soundName
@@ -534,6 +589,17 @@ object PacketLogger : Module(
534589
"data" to packet.data
535590
}
536591
}
592+
is SPacketSpawnPlayer -> {
593+
logServer(packet) {
594+
"entityID" to packet.entityID
595+
"uniqueID" to packet.uniqueId
596+
"x" to packet.x
597+
"y" to packet.y
598+
"z" to packet.z
599+
"yaw" to packet.yaw
600+
"pitch" to packet.pitch
601+
}
602+
}
537603
is SPacketTeams -> {
538604
logServer(packet) {
539605
"action" to packet.action
@@ -542,9 +608,11 @@ object PacketLogger : Module(
542608
}
543609
}
544610
is SPacketTimeUpdate -> {
545-
logServer(packet) {
546-
"totalWorldTime" to packet.totalWorldTime
547-
"worldTime" to packet.worldTime
611+
if (!ignoreTimeUpdates) {
612+
logServer(packet) {
613+
"totalWorldTime" to packet.totalWorldTime
614+
"worldTime" to packet.worldTime
615+
}
548616
}
549617
}
550618
is SPacketUnloadChunk -> {
@@ -581,17 +649,6 @@ object PacketLogger : Module(
581649
"windowId" to packet.windowId
582650
}
583651
}
584-
is SPacketEntity.S15PacketEntityRelMove -> {
585-
logServer(packet) {
586-
"x" to packet.x
587-
"y" to packet.y
588-
"z" to packet.z
589-
"yaw" to packet.yaw
590-
"pitch" to packet.pitch
591-
"isRotating" to packet.isRotating
592-
"onGround" to packet.onGround
593-
}
594-
}
595652
else -> {
596653
if (!ignoreUnknown) {
597654
logServer(packet) {
@@ -652,33 +709,41 @@ object PacketLogger : Module(
652709
}
653710
}
654711
is CPacketPlayer.Rotation -> {
655-
logClient(packet) {
656-
"yaw" to packet.playerYaw
657-
"pitch" to packet.playerPitch
658-
"onGround" to packet.isOnGround
712+
if (!ignorePlayerPosition) {
713+
logClient(packet) {
714+
"yaw" to packet.playerYaw
715+
"pitch" to packet.playerPitch
716+
"onGround" to packet.isOnGround
717+
}
659718
}
660719
}
661720
is CPacketPlayer.Position -> {
662-
logClient(packet) {
663-
"x" to packet.playerX
664-
"y" to packet.playerY
665-
"z" to packet.playerZ
666-
"onGround" to packet.isOnGround
721+
if (!ignorePlayerPosition) {
722+
logClient(packet) {
723+
"x" to packet.playerX
724+
"y" to packet.playerY
725+
"z" to packet.playerZ
726+
"onGround" to packet.isOnGround
727+
}
667728
}
668729
}
669730
is CPacketPlayer.PositionRotation -> {
670-
logClient(packet) {
671-
"x" to packet.playerX
672-
"y" to packet.playerY
673-
"z" to packet.playerZ
674-
"yaw" to packet.playerYaw
675-
"pitch" to packet.playerPitch
676-
"onGround" to packet.isOnGround
731+
if (!ignorePlayerPosition) {
732+
logClient(packet) {
733+
"x" to packet.playerX
734+
"y" to packet.playerY
735+
"z" to packet.playerZ
736+
"yaw" to packet.playerYaw
737+
"pitch" to packet.playerPitch
738+
"onGround" to packet.isOnGround
739+
}
677740
}
678741
}
679742
is CPacketPlayer -> {
680-
logClient(packet) {
681-
"onGround" to packet.isOnGround
743+
if (!ignorePlayerPosition) {
744+
logClient(packet) {
745+
"onGround" to packet.isOnGround
746+
}
682747
}
683748
}
684749
is CPacketPlayerDigging -> {

src/main/resources/mixins.lambda.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"accessor.network.AccessorSPacketEntityVelocity",
2828
"accessor.network.AccessorSPacketExplosion",
2929
"accessor.network.AccessorSPacketPosLook",
30+
"accessor.network.AccessorSPacketEntity",
31+
"accessor.network.AccessorSPacketEntityHeadLook",
3032
"accessor.player.AccessorEntityPlayerSP",
3133
"accessor.player.AccessorPlayerControllerMP",
3234
"accessor.render.AccessorRenderGlobal",

0 commit comments

Comments
 (0)