Introduced some debugging info into Forge packets. And a debug flag in the client and server packet handlers.
This commit is contained in:
parent
86adb815e6
commit
f8ad250cc7
7 changed files with 116 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,23 @@ 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<Integer, String> mod : Mods.entrySet())
|
||||
{
|
||||
ret.append(String.format(" %5d ", mod.getKey()) + mod.getValue() + '\n');
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,26 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue