当前位置: 首页>>代码示例>>Java>>正文


Java FMLOutboundHandler类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.network.FMLOutboundHandler的典型用法代码示例。如果您正苦于以下问题:Java FMLOutboundHandler类的具体用法?Java FMLOutboundHandler怎么用?Java FMLOutboundHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FMLOutboundHandler类属于net.minecraftforge.fml.common.network包,在下文中一共展示了FMLOutboundHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onConnectionCreated

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@SubscribeEvent
public void onConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    JustEnoughDimensions.logInfo("FMLNetworkEvent.ServerConnectionFromClientEvent: Syncing dimension data to client");
    DimensionSyncPacket packet = new DimensionSyncPacket();
    packet.addDimensionData(DimensionConfig.instance().getRegisteredDimensions());

    FMLEmbeddedChannel channel = JustEnoughDimensions.channels.get(Side.SERVER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.getManager().channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
    channel.writeOutbound(packet);
}
 
开发者ID:maruohon,项目名称:justenoughdimensions,代码行数:13,代码来源:JEDEventHandler.java

示例2: cleanAttributes

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
private void cleanAttributes(ChannelHandlerContext ctx)
{
    ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).remove();
    ctx.channel().attr(NetworkRegistry.NET_HANDLER).remove();
    ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).remove();
    this.handshakeChannel.attr(FML_DISPATCHER).remove();
    this.manager.channel().attr(FML_DISPATCHER).remove();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:NetworkDispatcher.java

示例3: channelRead0

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, REQ msg) throws Exception
{
    INetHandler iNetHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    MessageContext context = new MessageContext(iNetHandler, side);
    REPLY result = messageHandler.onMessage(msg, context);
    if (result != null)
    {
        ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY);
        ctx.writeAndFlush(result).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:SimpleChannelHandlerWrapper.java

示例4: registerChannel

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public static void registerChannel(FMLContainer container, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(container, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler());
    EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
    embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);

    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:FMLNetworkHandler.java

示例5: registerChannel

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
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());
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:ForgeNetworkHandler.java

示例6: userEventTriggered

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {

    if (evt instanceof NetworkHandshakeEstablished) {
        INetHandler netHandler = ((NetworkDispatcher) ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).get()).getNetHandler();
        if (netHandler instanceof NetHandlerPlayServer) {
            handler.handshakeReceived((NetHandlerPlayServer) netHandler);
        }
    } else {
        ctx.fireUserEventTriggered(evt);
    }
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:13,代码来源:PacketCustom.java

示例7: sendPacketToPlayer

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public static void sendPacketToPlayer(SimplePacket packet, EntityPlayer player)
{
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.PLAYER);
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet);
}
 
开发者ID:CyberdyneCC,项目名称:HazardousResearch,代码行数:8,代码来源:PacketHandler.java

示例8: sendPacketToAllPlayers

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public static void sendPacketToAllPlayers(SimplePacket packet)
{
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.ALL);
    PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet);

}
 
开发者ID:CyberdyneCC,项目名称:HazardousResearch,代码行数:8,代码来源:PacketHandler.java

示例9: sendToPlayer

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public void sendToPlayer( EntityPlayerMP player, Packet packet )
{
	Channel channel = channels.get( Side.SERVER );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.PLAYER );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( player );
	channel.writeAndFlush( packet );
}
 
开发者ID:spacechase0,项目名称:SpaceCore,代码行数:8,代码来源:PacketCodec.java

示例10: sendToNearby

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public void sendToNearby( NetworkRegistry.TargetPoint pos, Packet packet )
{
	Channel channel = channels.get( Side.SERVER );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( pos );
	channel.writeAndFlush( packet );
}
 
开发者ID:spacechase0,项目名称:SpaceCore,代码行数:8,代码来源:PacketCodec.java

示例11: sendToDimension

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public void sendToDimension( int dim, Packet packet )
{
	Channel channel = channels.get( Side.SERVER );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.DIMENSION );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( dim );
	channel.writeAndFlush( packet );
}
 
开发者ID:spacechase0,项目名称:SpaceCore,代码行数:8,代码来源:PacketCodec.java

示例12: sendToServer

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@SideOnly( Side.CLIENT )
public void sendToServer( Packet packet )
{
	Channel channel = channels.get( Side.CLIENT );
	channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.TOSERVER );
	channel.writeAndFlush( packet );
}
 
开发者ID:spacechase0,项目名称:SpaceCore,代码行数:8,代码来源:PacketCodec.java

示例13: channelRead0

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final NetworkEvent msg) throws Exception {
	NetUtils.executeSynchronized(ctx, () -> {
		// TODO asynchronous events, once needed
		MinecraftForge.EVENT_BUS.post(msg);
		msg.dispatcher = null;

		for (NetworkEvent reply : msg.replies) {
			ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.REPLY);
			ctx.writeAndFlush(reply);
		}
	});
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:14,代码来源:NetworkEventInboundHandler.java

示例14: write

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
	if (!(msg instanceof FMLProxyPacket)) {
		ctx.write(msg);
		return;
	}

	final Channel channel = ctx.channel();

	final IPacketTargetSelector<?> target = channel.attr(MESSAGETARGET).get();
	if (target == null) {
		ctx.write(msg);
		return;
	}

	final FMLProxyPacket pkt = (FMLProxyPacket)msg;

	final Side channelSide = channel.attr(NetworkRegistry.CHANNEL_SOURCE).get();

	Preconditions.checkState(target.isAllowedOnSide(channelSide), "Packet not allowed on side");

	final String channelName = channel.attr(NetworkRegistry.FML_CHANNEL).get();

	Object arg = channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).get();

	try {
		final Collection<NetworkDispatcher> dispatchers = getDispatchers(target, arg);
		for (NetworkDispatcher dispatcher : dispatchers)
			dispatcher.sendProxy(pkt);

	} catch (Throwable t) {

		throw new IllegalStateException(String.format(
				"Failed to select and send message (selector %s, arg: %s, channel: %s, side: %s)",
				target, arg, channelName, channelSide), t);
	}

}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:39,代码来源:ExtendedOutboundHandler.java

示例15: sendPacketToPlayer

import net.minecraftforge.fml.common.network.FMLOutboundHandler; //导入依赖的package包/类
public static void sendPacketToPlayer(FFSPacket packet, EntityPlayer player) {
	FMLEmbeddedChannel channel = channels.get(Side.SERVER);
	channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
	channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
	channel.writeOutbound(packet);
}
 
开发者ID:Lordmau5,项目名称:FFS,代码行数:7,代码来源:NetworkHandler.java


注:本文中的net.minecraftforge.fml.common.network.FMLOutboundHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。