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 2611ee1ec..fa8430b22 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 @@ -75,11 +75,11 @@ import org.apache.logging.log4j.Level; public class NetworkDispatcher extends SimpleChannelInboundHandler> implements ChannelOutboundHandler { private static boolean DEBUG_HANDSHAKE = Boolean.parseBoolean(System.getProperty("fml.debugNetworkHandshake", "false")); private static enum ConnectionState { - OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, FINALIZING, CONNECTED; + OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, FINALIZING, CONNECTED } private static enum ConnectionType { - MODDED, BUKKIT, VANILLA; + MODDED, BUKKIT, VANILLA } public static NetworkDispatcher get(NetworkManager manager) @@ -116,20 +116,6 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler> im private Map modList; private int overrideLoginDim; - private static final Field ordered; - - static { - try - { - ordered = Class.forName("io.netty.channel.AbstractChannelHandlerContext").getDeclaredField("ordered"); - ordered.setAccessible(true); - } - catch (NoSuchFieldException | ClassNotFoundException e) - { - FMLLog.log(Level.FATAL, "WOW, Netty changed, ****HAXXXXX****", e); - throw new Error(e); - } - } public NetworkDispatcher(NetworkManager manager) { super(false); @@ -188,32 +174,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler> im { this.manager.channel().config().setAutoRead(false); // Insert ourselves into the pipeline - final ChannelPipeline cp = this.manager.channel().pipeline().addBefore("packet_handler", "fml:packet_handler", this); - // THIS IS A GHASTLY HACK TO FIX A STUPID "FEATURE" IN NETTY - // We force the "AbstractChannelHandlerContext" order field to false - because we don't want - // our handshake handler to "WAIT" until it's completed the "handlerAdded" method, before becoming active - // in the pipeline - final ChannelHandlerContext context = cp.context(this); - try - { - ordered.set(context, false); - } - catch (IllegalAccessException e) - { - FMLLog.log(Level.FATAL, "Wow, that reflection failed!", e); - throw new Error(e); - } - - } - - public void clientToServerHandshake() - { - insertIntoChannel(); - } - - @Override - public void handlerAdded(ChannelHandlerContext ctx) throws Exception - { + this.manager.channel().pipeline().addBefore("packet_handler", "fml:packet_handler", this); if (this.state != null) { FMLLog.getLogger().log(Level.INFO, "Opening channel which already seems to have a state set. This is a vanilla connection. Handshake handler will stop now"); this.manager.channel().config().setAutoRead(true); @@ -226,6 +187,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler> im this.manager.channel().config().setAutoRead(true); } + public void clientToServerHandshake() + { + insertIntoChannel(); + } + int serverInitiateHandshake() { // Send mod salutation to the client