Search in sources :

Example 1 with FMLEmbeddedChannel

use of net.minecraftforge.fml.common.network.FMLEmbeddedChannel in project MinecraftForge by MinecraftForge.

the class ForgeNetworkHandler method addClientHandlers.

@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());
}
Also used : FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with FMLEmbeddedChannel

use of net.minecraftforge.fml.common.network.FMLEmbeddedChannel in project MinecraftForge by MinecraftForge.

the class ForgeNetworkHandler method registerChannel.

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());
}
Also used : FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel)

Example 3 with FMLEmbeddedChannel

use of net.minecraftforge.fml.common.network.FMLEmbeddedChannel in project MinecraftForge by MinecraftForge.

the class SimpleNetworkWrapper method registerMessage.

/**
     * Register a message and it's associated handler. The message will have the supplied discriminator byte. The message handler will
     * be registered on the supplied side (this is the side where you want the message to be processed and acted upon).
     *
     * @param messageHandler the message handler instance
     * @param requestMessageType the message type
     * @param discriminator a discriminator byte
     * @param side the side for the handler
     */
public <REQ extends IMessage, REPLY extends IMessage> void registerMessage(IMessageHandler<? super REQ, ? extends REPLY> messageHandler, Class<REQ> requestMessageType, int discriminator, Side side) {
    packetCodec.addDiscriminator(discriminator, requestMessageType);
    FMLEmbeddedChannel channel = channels.get(side);
    String type = channel.findChannelHandlerNameForType(SimpleIndexedCodec.class);
    if (side == Side.SERVER) {
        addServerHandlerAfter(channel, type, messageHandler, requestMessageType);
    } else {
        addClientHandlerAfter(channel, type, messageHandler, requestMessageType);
    }
}
Also used : FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel)

Example 4 with FMLEmbeddedChannel

use of net.minecraftforge.fml.common.network.FMLEmbeddedChannel in project SpongeForge by SpongePowered.

the class MixinWorldManager method sendDimensionRegistration.

@Overwrite
public static void sendDimensionRegistration(EntityPlayerMP player, WorldProvider provider) {
    // register dimension on client-side
    if (((IMixinEntityPlayerMP) player).usesCustomClient()) {
        FMLEmbeddedChannel serverChannel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
        serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
        serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
        serverChannel.writeOutbound(new ForgeMessage.DimensionRegisterMessage(provider.getDimension(), provider.getDimensionType().name()));
    }
}
Also used : ForgeMessage(net.minecraftforge.common.network.ForgeMessage) IMixinEntityPlayerMP(org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayerMP) FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 5 with FMLEmbeddedChannel

use of net.minecraftforge.fml.common.network.FMLEmbeddedChannel in project Galacticraft by micdoodle8.

the class PacketCustom method assignHandler.

public static void assignHandler(Object channelKey, ICustomPacketHandler handler) {
    String channelName = channelName(channelKey);
    Side side = handler instanceof IServerPacketHandler ? Side.SERVER : Side.CLIENT;
    FMLEmbeddedChannel channel = getOrCreateChannel(channelName, side);
    channel.attr(cclHandler).get().handlers.put(side, side == Side.SERVER ? new ServerInboundHandler(handler) : new ClientInboundHandler(handler));
}
Also used : Side(net.minecraftforge.fml.relauncher.Side) FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel)

Aggregations

FMLEmbeddedChannel (net.minecraftforge.fml.common.network.FMLEmbeddedChannel)8 Side (net.minecraftforge.fml.relauncher.Side)2 PacketHandler (logisticspipes.network.PacketHandler)1 PacketInboundHandler (logisticspipes.network.PacketInboundHandler)1 ForgeMessage (net.minecraftforge.common.network.ForgeMessage)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1 IMixinEntityPlayerMP (org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayerMP)1