Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PacketLogger Revamp #557

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketClientSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = CPacketClientSettings.class)
public interface AccessorCPacketClientSettings {
@Accessor(value = "view")
int getView();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketConfirmTransaction;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = CPacketConfirmTransaction.class)
public interface AccessorCPacketConfirmTransaction {
@Accessor(value = "accepted")
boolean getAccepted();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketPlayerAbilities;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = CPacketPlayerAbilities.class)
public interface AccessorCPacketPlayerAbilities {
@Accessor(value = "flySpeed")
float getFlySpeed();
@Accessor(value = "walkSpeed")
float getWalkSpeed();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketResourcePackStatus;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = CPacketResourcePackStatus.class)
public interface AccessorCPacketResourcePackStatus {
@Accessor(value = "action")
CPacketResourcePackStatus.Action getAction();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketSpectate;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.UUID;

@Mixin(value = CPacketSpectate.class)
public interface AccessorCPacketSpectate {
@Accessor(value = "id")
UUID getId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.client.CPacketVehicleMove;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = CPacketVehicleMove.class)
public interface AccessorCPacketVehicleMove {
@Accessor(value = "x")
void setX(double x);

@Accessor(value = "y")
void setY(double y);

@Accessor(value = "z")
void setZ(double z);

@Accessor(value = "yaw")
void setYaw(float yaw);

@Accessor(value = "pitch")
void setPitch(float pitch);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.client.network.NetHandlerPlayClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = NetHandlerPlayClient.class)
public interface AccessorNetHandlerPlayClient {

@Accessor(value = "doneLoadingTerrain")
boolean isDoneLoadingTerrain();

@Accessor(value = "doneLoadingTerrain")
void setDoneLoadingTerrain(boolean loaded);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.server.SPacketCloseWindow;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = SPacketCloseWindow.class)
public interface AccessorSPacketCloseWindow {
@Accessor(value = "windowId")
int getWindowId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.server.SPacketMaps;
import net.minecraft.world.storage.MapDecoration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = SPacketMaps.class)
public interface AccessorSPacketMaps {
@Accessor(value = "mapScale")
byte getMapScale();
@Accessor(value = "trackingPosition")
boolean getTrackingPosition();
@Accessor(value = "icons")
MapDecoration[] getIcons();
@Accessor(value = "minX")
int getMinX();
@Accessor(value = "minZ")
int getMinZ();
@Accessor(value = "columns")
int getColumns();
@Accessor(value = "rows")
int getRows();
@Accessor(value = "mapDataBytes")
byte[] getMapDataBytes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.lambda.mixin.accessor.network;

import net.minecraft.network.play.server.SPacketWorldBorder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = SPacketWorldBorder.class)
public interface AccessorSPacketWorldBorder {
@Accessor(value = "action")
SPacketWorldBorder.Action getAction();
@Accessor(value = "size")
int getSize();
@Accessor(value = "centerX")
double getCenterX();
@Accessor(value = "centerZ")
double getCenterZ();
@Accessor(value = "targetSize")
double getTargetSize();
@Accessor(value = "diameter")
double getDiameter();
@Accessor(value = "timeUntilTarget")
long getTimeUntilTarget();
@Accessor(value = "warningTime")
int getWarningTime();
@Accessor(value = "warningDistance")
int getWarningDistance();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.lambda.client.gui.hudgui.elements.misc

import com.lambda.client.event.SafeClientEvent
import com.lambda.client.gui.hudgui.LabelHud
import com.lambda.client.module.modules.player.PacketLogger
import java.util.*

internal object PacketLogViewer: LabelHud(
name = "PacketLogViewer",
category = Category.MISC,
description = "Displays the packet log"
) {

private val maxLines by setting("Max Lines", 50, 1..200, 1)
private val logs: MutableList<String> = Collections.synchronizedList(mutableListOf())
private val onlyWhenLoggerEnabled by setting("Only When Logger Enabled", true)
private val clearButton by setting("Clear", false, consumer = { _, _ ->
clear()
false
})

init {
visibleSetting.valueListeners.add { _, it ->
if (!it) {
clear()
}
}
}

override fun SafeClientEvent.updateText() {
displayText.clear()
if (onlyWhenLoggerEnabled && PacketLogger.isDisabled) return
if (logs.isNotEmpty() && (PacketLogger.logMode == PacketLogger.LogMode.ALL || PacketLogger.logMode == PacketLogger.LogMode.ONLY_HUD)) {
displayText.addLine("PacketLog Viewer", secondaryColor)
synchronized(logs) {
logs.forEach { log ->
log.split(",").forEachIndexed { i, s ->
displayText.add(s, if (i % 2 == 0) secondaryColor else primaryColor)
}
displayText.addLine("")
}
}
}
}

fun addPacketLog(log: String) {
synchronized(logs) {
logs.add(log)
if (logs.size > maxLines) {
logs.removeAt(0)
}
}
}

fun clear() {
synchronized(logs) {
logs.clear()
}
}
}
Loading