diff --git a/forge/forge_client/src/net/minecraft/src/forge/PacketHandlerClient.java b/forge/forge_client/src/net/minecraft/src/forge/PacketHandlerClient.java index 81cbf5ef5..ea11cc333 100644 --- a/forge/forge_client/src/net/minecraft/src/forge/PacketHandlerClient.java +++ b/forge/forge_client/src/net/minecraft/src/forge/PacketHandlerClient.java @@ -16,6 +16,8 @@ import net.minecraft.src.forge.packets.*; public class PacketHandlerClient implements IPacketHandler { + private static boolean DEBUG = false; + @Override public void onPacketData(NetworkManager network, String channel, byte[] bytes) { @@ -77,6 +79,10 @@ public class PacketHandlerClient implements IPacketHandler */ public void onEntitySpawnPacket(PacketEntitySpawn packet, DataInputStream data, World world) { + if (DEBUG) + { + System.out.println("S->C: " + packet.toString(true)); + } Class cls = MinecraftForge.getEntityClass(packet.modID, packet.typeID); if (cls == null) { @@ -142,6 +148,10 @@ public class PacketHandlerClient implements IPacketHandler */ private void onModListCheck(NetClientHandler net) { + if (DEBUG) + { + System.out.println("S->C: " + (new PacketModList(false)).toString(true)); + } PacketModList pkt = new PacketModList(false); pkt.Mods = new String[ModLoader.getLoadedMods().size()]; int x = 0; @@ -150,6 +160,10 @@ public class PacketHandlerClient implements IPacketHandler pkt.Mods[x++] = mod.toString(); } net.addToSendQueue(pkt.getPacket()); + if (DEBUG) + { + System.out.println("C->S: " + pkt.toString(true)); + } } /** @@ -161,6 +175,10 @@ public class PacketHandlerClient implements IPacketHandler */ private void onMissingMods(PacketMissingMods pkt, NetClientHandler net) { + if (DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } net.disconnect(); Minecraft mc = ModLoader.getMinecraftInstance(); mc.changeWorld1(null); @@ -176,6 +194,10 @@ public class PacketHandlerClient implements IPacketHandler */ private void onModIDs(PacketModIDs pkt) { + if (DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } ForgeHooks.networkMods.clear(); NetworkMod[] mods = MinecraftForge.getNetworkMods(); for (NetworkMod mod : mods) @@ -206,6 +228,10 @@ public class PacketHandlerClient implements IPacketHandler */ private void onOpenGui(PacketOpenGUI pkt) { + if (DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } NetworkMod mod = MinecraftForge.getModByID(pkt.ModID); if (mod != null) { diff --git a/forge/forge_common/net/minecraft/src/forge/packets/ForgePacket.java b/forge/forge_common/net/minecraft/src/forge/packets/ForgePacket.java index 04bc2a977..07f394ac0 100644 --- a/forge/forge_common/net/minecraft/src/forge/packets/ForgePacket.java +++ b/forge/forge_common/net/minecraft/src/forge/packets/ForgePacket.java @@ -47,4 +47,14 @@ public abstract class ForgePacket public abstract void writeData(DataOutputStream data) throws IOException; public abstract void readData(DataInputStream data) throws IOException; public abstract int getID(); + public String toString(boolean full) + { + return toString(); + } + + @Override + public String toString() + { + return getID() + " " + getClass().getSimpleName(); + } } diff --git a/forge/forge_common/net/minecraft/src/forge/packets/PacketModIDs.java b/forge/forge_common/net/minecraft/src/forge/packets/PacketModIDs.java index 6a3298823..ec31518bd 100644 --- a/forge/forge_common/net/minecraft/src/forge/packets/PacketModIDs.java +++ b/forge/forge_common/net/minecraft/src/forge/packets/PacketModIDs.java @@ -37,5 +37,24 @@ public class PacketModIDs extends ForgePacket { return ForgePacket.MOD_IDS; } + + @Override + public String toString(boolean full) + { + if (full) + { + StringBuilder ret = new StringBuilder(); + ret.append(toString()).append('\n'); + for (Entry mod : Mods.entrySet()) + { + ret.append(String.format(" %5d ", mod.getKey()) + mod.getValue() + '\n'); + } + return ret.toString(); + } + else + { + return toString(); + } + } } diff --git a/forge/forge_common/net/minecraft/src/forge/packets/PacketModList.java b/forge/forge_common/net/minecraft/src/forge/packets/PacketModList.java index 47191f67a..cb85a1db8 100644 --- a/forge/forge_common/net/minecraft/src/forge/packets/PacketModList.java +++ b/forge/forge_common/net/minecraft/src/forge/packets/PacketModList.java @@ -54,5 +54,27 @@ public class PacketModList extends ForgePacket { return ForgePacket.MODLIST; } + + @Override + public String toString(boolean full) + { + if (full) + { + StringBuilder ret = new StringBuilder(); + ret.append(toString()).append('\n'); + if (Mods != null) + { + for (String mod : Mods) + { + ret.append(" " + mod + '\n'); + } + } + return ret.toString(); + } + else + { + return toString(); + } + } } diff --git a/forge/forge_common/net/minecraft/src/forge/packets/PacketOpenGUI.java b/forge/forge_common/net/minecraft/src/forge/packets/PacketOpenGUI.java index f2939e42f..00857712c 100644 --- a/forge/forge_common/net/minecraft/src/forge/packets/PacketOpenGUI.java +++ b/forge/forge_common/net/minecraft/src/forge/packets/PacketOpenGUI.java @@ -3,6 +3,7 @@ package net.minecraft.src.forge.packets; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.Map.Entry; public class PacketOpenGUI extends ForgePacket { @@ -51,4 +52,25 @@ public class PacketOpenGUI extends ForgePacket { return ForgePacket.OPEN_GUI; } + + @Override + public String toString(boolean full) + { + if (full) + { + StringBuilder ret = new StringBuilder(); + ret.append(toString() + '\n'); + ret.append(" Window: " + WindowID + '\n'); + ret.append(" Mod: " + ModID + '\n'); + ret.append(" Gui: " + GuiID + '\n'); + ret.append(" X: " + X + '\n'); + ret.append(" Y: " + Y + '\n'); + ret.append(" Z: " + Z + '\n'); + return ret.toString(); + } + else + { + return toString(); + } + } } diff --git a/forge/forge_server/src/net/minecraft/src/forge/ForgeHooksServer.java b/forge/forge_server/src/net/minecraft/src/forge/ForgeHooksServer.java index 682cc6499..2f1bb6785 100644 --- a/forge/forge_server/src/net/minecraft/src/forge/ForgeHooksServer.java +++ b/forge/forge_server/src/net/minecraft/src/forge/ForgeHooksServer.java @@ -30,6 +30,10 @@ public class ForgeHooksServer { PacketModList pkt = new PacketModList(true); ((NetServerHandler)net.getNetHandler()).sendPacket(pkt.getPacket()); + if (((PacketHandlerServer)ForgeHooks.getPacketHandler()).DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } } diff --git a/forge/forge_server/src/net/minecraft/src/forge/PacketHandlerServer.java b/forge/forge_server/src/net/minecraft/src/forge/PacketHandlerServer.java index eaca8c126..b63eda048 100644 --- a/forge/forge_server/src/net/minecraft/src/forge/PacketHandlerServer.java +++ b/forge/forge_server/src/net/minecraft/src/forge/PacketHandlerServer.java @@ -16,6 +16,7 @@ import net.minecraft.src.forge.packets.*; public class PacketHandlerServer implements IPacketHandler { + public static boolean DEBUG = false; @Override public void onPacketData(NetworkManager network, String channel, byte[] bytes) { @@ -44,6 +45,10 @@ public class PacketHandlerServer implements IPacketHandler private void onModListResponse(NetServerHandler net, PacketModList pkt) throws IOException { + if (DEBUG) + { + System.out.println("C->S: " + pkt.toString(true)); + } if (pkt.Length < 0) { net.kickPlayer("Invalid mod list response, Size: " + pkt.Length); @@ -105,6 +110,10 @@ public class PacketHandlerServer implements IPacketHandler { pkt.Mods[x++] = mod.toString(); } + if (DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } net.sendPacket(pkt.getPacket()); disconnectUser(net); } @@ -125,6 +134,10 @@ public class PacketHandlerServer implements IPacketHandler pkt.Mods.put(MinecraftForge.getModID(mod), mod.toString()); } net.sendPacket(pkt.getPacket()); + if (DEBUG) + { + System.out.println("S->C: " + pkt.toString(true)); + } } /**