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());
}
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());
}
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);
}
}
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()));
}
}
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));
}
Aggregations