@SideOnly(Side.CLIENT)
 private static void addClientHandlers() {
   FMLEmbeddedChannel clientChannel = channelPair.get(Side.CLIENT);
   String handlerName = clientChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class);
   clientChannel
       .pipeline()
       .addAfter(handlerName, "DimensionHandler", new DimensionMessageHandler());
   clientChannel
       .pipeline()
       .addAfter(handlerName, "FluidIdRegistryHandler", new FluidIdRegistryMessageHandler());
 }
  public static void registerChannel(ForgeModContainer forgeModContainer, Side side) {
    channelPair =
        NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec());
    if (side == Side.CLIENT) {
      addClientHandlers();
    }

    FMLEmbeddedChannel serverChannel = channelPair.get(Side.SERVER);
    serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);
    String handlerName = serverChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class);
    serverChannel
        .pipeline()
        .addAfter(
            handlerName,
            "ServerToClientConnection",
            new ServerToClientConnectionEstablishedHandler());
  }
  public static void init() {
    if (!channels.isEmpty()) // avoid duplicate inits..
    return;

    Codec codec = new Codec();

    codec.addDiscriminator(0, PacketMachine.class);
    codec.addDiscriminator(1, PacketEntity.class);
    codec.addDiscriminator(2, PacketDimInfo.class);
    codec.addDiscriminator(3, PacketSatellite.class);
    codec.addDiscriminator(4, PacketStellarInfo.class);
    codec.addDiscriminator(5, PacketItemModifcation.class);

    channels.putAll(
        NetworkRegistry.INSTANCE.newChannel(AdvancedRocketry.modId, codec, new HandlerServer()));

    // add handlers
    if (FMLCommonHandler.instance().getSide().isClient()) {
      // for the client
      FMLEmbeddedChannel channel = channels.get(Side.CLIENT);
      String codecName = channel.findChannelHandlerNameForType(Codec.class);
      channel.pipeline().addAfter(codecName, "ClientHandler", new HandlerClient());
    }
  }