本文整理汇总了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);
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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());
}
示例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);
}
}
示例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);
}
示例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);
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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);
}
});
}
示例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);
}
}
示例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);
}