3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-03 08:41:05 +02:00

Code Cleanup, remove some of the output debug (Packet debug is still there)

Dieser Commit ist enthalten in:
Myles 2016-02-29 13:26:06 +00:00
Ursprung 3fa4b7a7b2
Commit 1a1ffe4265
2 geänderte Dateien mit 7 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -42,17 +42,14 @@ public class IncomingTransformer {
System.out.println("Packet Type: " + packet + " New ID: " + packetID + " Original: " + original); System.out.println("Packet Type: " + packet + " New ID: " + packetID + " Original: " + original);
} }
if (packet == PacketType.PLAY_TP_CONFIRM) { if (packet == PacketType.PLAY_TP_CONFIRM) {
System.out.println("Cancelling TP Confirm");
throw new CancelException(); throw new CancelException();
} }
PacketUtil.writeVarInt(packetID, output); PacketUtil.writeVarInt(packetID, output);
if (packet == PacketType.HANDSHAKE) { if (packet == PacketType.HANDSHAKE) {
System.out.println("Readable Bytes: " + input.readableBytes());
int protVer = PacketUtil.readVarInt(input); int protVer = PacketUtil.readVarInt(input);
info.setProtocol(protVer); info.setProtocol(protVer);
PacketUtil.writeVarInt(protVer <= 102 ? protVer : 47, output); // pretend to be older PacketUtil.writeVarInt(protVer <= 102 ? protVer : 47, output); // pretend to be older
System.out.println("Incoming prot ver: " + protVer);
if (protVer <= 102) { if (protVer <= 102) {
// Not 1.9 remove pipes // Not 1.9 remove pipes
this.init.remove(); this.init.remove();
@ -137,13 +134,11 @@ public class IncomingTransformer {
short skinParts = input.readUnsignedByte(); short skinParts = input.readUnsignedByte();
output.writeByte(skinParts); output.writeByte(skinParts);
int mainHand = PacketUtil.readVarInt(input); PacketUtil.readVarInt(input);
System.out.println("Main hand: " + mainHand);
return; return;
} }
if (packet == PacketType.PLAY_ANIMATION_REQUEST) { if (packet == PacketType.PLAY_ANIMATION_REQUEST) {
int hand = PacketUtil.readVarInt(input); PacketUtil.readVarInt(input);
System.out.println("Animation request " + hand);
return; return;
} }
if (packet == PacketType.PLAY_USE_ENTITY) { if (packet == PacketType.PLAY_USE_ENTITY) {
@ -161,7 +156,7 @@ public class IncomingTransformer {
output.writeFloat(targetZ); output.writeFloat(targetZ);
} }
if (type == 0 || type == 2) { if (type == 0 || type == 2) {
int hand = PacketUtil.readVarInt(input); // lel PacketUtil.readVarInt(input);
} }
return; return;
} }
@ -171,7 +166,6 @@ public class IncomingTransformer {
int face = PacketUtil.readVarInt(input); int face = PacketUtil.readVarInt(input);
output.writeByte(face); output.writeByte(face);
int hand = PacketUtil.readVarInt(input); int hand = PacketUtil.readVarInt(input);
System.out.println("hand: " + hand);
// write item in hand // write item in hand
output.writeShort(-1); output.writeShort(-1);
@ -189,8 +183,6 @@ public class IncomingTransformer {
// Simulate using item :) // Simulate using item :)
output.writeLong(-1L); output.writeLong(-1L);
output.writeByte(-1); output.writeByte(-1);
int hand = PacketUtil.readVarInt(input);
System.out.println("hand: " + hand);
// write item in hand // write item in hand
output.writeShort(-1); output.writeShort(-1);

Datei anzeigen

@ -48,7 +48,7 @@ public class OutgoingTransformer {
if (packet == null) { if (packet == null) {
throw new RuntimeException("Outgoing Packet not found? " + packetID + " State: " + info.getState() + " Version: " + info.getProtocol()); throw new RuntimeException("Outgoing Packet not found? " + packetID + " State: " + info.getState() + " Version: " + info.getProtocol());
} }
if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE) if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE && !packet.name().toLowerCase().contains("entity"))
System.out.println("Packet Type: " + packet + " Original ID: " + packetID + " State:" + info.getState()); System.out.println("Packet Type: " + packet + " Original ID: " + packetID + " State:" + info.getState());
if (packet.getPacketID() != -1) { if (packet.getPacketID() != -1) {
packetID = packet.getNewPacketID(); packetID = packet.getNewPacketID();
@ -58,7 +58,6 @@ public class OutgoingTransformer {
PacketUtil.writeVarInt(packetID, output); PacketUtil.writeVarInt(packetID, output);
if (packet == PacketType.PLAY_NAMED_SOUND_EFFECT) { if (packet == PacketType.PLAY_NAMED_SOUND_EFFECT) {
// TODO: Port this over // TODO: Port this over
System.out.println("cancelling");
throw new CancelException(); throw new CancelException();
} }
if (packet == PacketType.PLAY_ATTACH_ENTITY) { if (packet == PacketType.PLAY_ATTACH_ENTITY) {
@ -113,11 +112,11 @@ public class OutgoingTransformer {
if (packet == PacketType.PLAY_ENTITY_RELATIVE_MOVE) { if (packet == PacketType.PLAY_ENTITY_RELATIVE_MOVE) {
int id = PacketUtil.readVarInt(input); int id = PacketUtil.readVarInt(input);
PacketUtil.writeVarInt(id, output); PacketUtil.writeVarInt(id, output);
int x = input.readByte(); short x = (short) (input.readByte());
output.writeShort(x); output.writeShort(x);
int y = input.readByte(); short y = (short) (input.readByte());
output.writeShort(y); output.writeShort(y);
int z = input.readByte(); short z = (short) (input.readByte());
output.writeShort(z); output.writeShort(z);
boolean onGround = input.readBoolean(); boolean onGround = input.readBoolean();
@ -290,12 +289,7 @@ public class OutgoingTransformer {
output.writeByte(pitch); output.writeByte(pitch);
byte yaw = input.readByte(); byte yaw = input.readByte();
output.writeByte(yaw); output.writeByte(yaw);
// We don't use currentItem short lel
// transform entity meta data ugh
// get data watcher
try { try {
System.out.println("Last Packet Type: " + info.getLastPacket().getClass().getName());
DataWatcher dw = Core.getPrivateField(info.getLastPacket(), "i", DataWatcher.class); DataWatcher dw = Core.getPrivateField(info.getLastPacket(), "i", DataWatcher.class);
transformMetadata(dw, output); transformMetadata(dw, output);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
@ -333,7 +327,6 @@ public class OutgoingTransformer {
input.readBytes(data); input.readBytes(data);
boolean sk = false; boolean sk = false;
if (info.getLastPacket() instanceof PacketPlayOutMapChunkBulk) { if (info.getLastPacket() instanceof PacketPlayOutMapChunkBulk) {
try { try {
sk = Core.getPrivateField(info.getLastPacket(), "d", boolean.class); sk = Core.getPrivateField(info.getLastPacket(), "d", boolean.class);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
@ -450,14 +443,12 @@ public class OutgoingTransformer {
break; break;
case Position: case Position:
BlockPosition blockposition = (BlockPosition) obj.b(); BlockPosition blockposition = (BlockPosition) obj.b();
packetdataserializer.writeInt(blockposition.getX()); packetdataserializer.writeInt(blockposition.getX());
packetdataserializer.writeInt(blockposition.getY()); packetdataserializer.writeInt(blockposition.getY());
packetdataserializer.writeInt(blockposition.getZ()); packetdataserializer.writeInt(blockposition.getZ());
break; break;
case Vector3F: case Vector3F:
Vector3f vector3f = (Vector3f) obj.b(); Vector3f vector3f = (Vector3f) obj.b();
packetdataserializer.writeFloat(vector3f.getX()); packetdataserializer.writeFloat(vector3f.getX());
packetdataserializer.writeFloat(vector3f.getY()); packetdataserializer.writeFloat(vector3f.getY());
packetdataserializer.writeFloat(vector3f.getZ()); packetdataserializer.writeFloat(vector3f.getZ());