Fix Debug packet logger on local memory connections.

This commit is contained in:
Lex Manos 2015-03-04 21:00:31 -08:00
parent 4d4f82816f
commit 418b7794d2
2 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,14 @@
--- ../src-base/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java
+++ ../src-work/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java
@@ -47,7 +47,11 @@
public void func_148840_b(PacketBuffer p_148840_1_) throws IOException
{
p_148840_1_.func_180714_a(this.field_149562_a);
+ synchronized(this) { //This may be access multiple times, from multiple threads, lets be safe.
+ this.field_149561_c.markReaderIndex();
p_148840_1_.writeBytes((ByteBuf)this.field_149561_c);
+ this.field_149561_c.resetReaderIndex();
+ }
}
public void func_148833_a(INetHandlerPlayServer p_148833_1_)

View file

@ -30,17 +30,19 @@ public class PacketLoggingHandler
{
pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler<Packet>()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C");
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
msg.writePacketData(buf);
FMLLog.log(Level.DEBUG, "$s $s:\n%s", msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
FMLLog.log(Level.DEBUG, "%s %s:\n%s", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
ctx.fireChannelRead(msg);
}
});
pipeline.addBefore("splitter", "prepender", new ChannelOutboundHandlerAdapter()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S");
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
@ -48,7 +50,7 @@ public class PacketLoggingHandler
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
((Packet)msg).writePacketData(buf);
FMLLog.log(Level.DEBUG, "$s $s:\n%s", msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
FMLLog.log(Level.DEBUG, "%s %s:\n%s", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
}
ctx.write(msg, promise);
}