package net.minecraftforge.common.network;

import io.netty.channel.embedded.EmbeddedChannel;

import java.util.EnumMap;

import net.minecraftforge.common.ForgeModContainer;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.internal.FMLRuntimeCodec;
import cpw.mods.fml.common.network.internal.HandshakeCompletionHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ForgeNetworkHandler
{
    private static EnumMap<Side, EmbeddedChannel> channelPair;

    public static void registerChannel(ForgeModContainer forgeModContainer, Side side)
    {
        channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec(), new HandshakeCompletionHandler());
        EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
        embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);

        if (side == Side.CLIENT)
        {
            addClientHandlers();
        }
        channelPair.get(Side.SERVER).pipeline().addAfter("ForgeRuntimeCodec#0", "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler());
    }

    @SideOnly(Side.CLIENT)
    private static void addClientHandlers()
    {
        channelPair.get(Side.CLIENT).pipeline().addAfter("ForgeRuntimeCodec#0", "DimensionHandler", new DimensionMessageHandler());
        channelPair.get(Side.CLIENT).pipeline().addAfter("ForgeRuntimeCodec#0", "FluidIdRegistryHandler", new FluidIdRegistryMessageHandler());
    }
}

@@ -1199,32 +1199,66 @@
 ine().addAfter(%22
+net.minecraftforge.common.network.
 ForgeRuntimeCode
@@ -1476,32 +1476,66 @@
 ine().addAfter(%22
+net.minecraftforge.common.network.
 ForgeRuntimeCode
@@ -1650,16 +1650,50 @@
 dAfter(%22
+net.minecraftforge.common.network.
 ForgeRun

Fix the network handler for forge