diff --git a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java index 7d88e96e47..90f55f6dfd 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java +++ b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java @@ -344,39 +344,18 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler> im } private MultiPartCustomPayload multipart = null; + private boolean handleClientSideCustomPacket(SPacketCustomPayload msg, ChannelHandlerContext context) { String channelName = msg.getChannelName(); if ("FML|MP".equals(channelName)) { - try + boolean result = handleMultiPartCustomPacket(msg, context); + if (result) { - if (multipart == null) - { - multipart = new MultiPartCustomPayload(msg.getBufferData()); - } - else - { - multipart.processPart(msg.getBufferData()); - } - } - catch (IOException e) - { - this.kickWithMessage(e.getMessage()); - multipart = null; - return true; - } - - if (multipart.isComplete()) - { - msg = multipart; - channelName = msg.getChannelName(); - multipart = null; - } - else - { - return true; // Haven't received all so return till we have. + msg.getBufferData().release(); } + return result; } if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName)) { @@ -407,6 +386,37 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler> im return false; } + private boolean handleMultiPartCustomPacket(SPacketCustomPayload msg, ChannelHandlerContext context) + { + try + { + if (multipart == null) + { + multipart = new MultiPartCustomPayload(msg.getBufferData()); + } + else + { + multipart.processPart(msg.getBufferData()); + } + } + catch (IOException e) + { + this.kickWithMessage(e.getMessage()); + multipart = null; + return true; + } + if (multipart.isComplete()) + { + boolean result = handleClientSideCustomPacket(multipart, context); + multipart = null; + return result; + } + else + { + return true; // Haven't received all so return till we have. + } + } + private boolean handleServerSideCustomPacket(CPacketCustomPayload msg, ChannelHandlerContext context) { if (state == ConnectionState.AWAITING_HANDSHAKE)