本文整理汇总了Java中net.minecraftforge.fml.common.network.handshake.NetworkDispatcher类的典型用法代码示例。如果您正苦于以下问题:Java NetworkDispatcher类的具体用法?Java NetworkDispatcher怎么用?Java NetworkDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkDispatcher类属于net.minecraftforge.fml.common.network.handshake包,在下文中一共展示了NetworkDispatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: selectNetworks
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
{
int dimension = (Integer)args;
ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.builder();
for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList())
{
if (dimension == player.dimension)
{
NetworkDispatcher dispatcher = player.connection.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
// Null dispatchers may exist for fake players - skip them
if (dispatcher != null) builder.add(dispatcher);
}
}
return builder.build();
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:FMLOutboundHandler.java
示例2: onConnectionCreated
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的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
示例3: forwardHandshake
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public static List<FMLProxyPacket> forwardHandshake(CompleteHandshake push, NetworkDispatcher target, Side side)
{
channelPair.get(side).attr(NetworkDispatcher.FML_DISPATCHER).set(target);
channelPair.get(side).writeOutbound(push);
ArrayList<FMLProxyPacket> list = new ArrayList<FMLProxyPacket>();
for (Object o: channelPair.get(side).outboundMessages())
{
list.add((FMLProxyPacket)o);
}
channelPair.get(side).outboundMessages().clear();
return list;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:FMLNetworkHandler.java
示例4: validateArgs
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public void validateArgs(Object args)
{
if (!(args instanceof NetworkDispatcher))
{
throw new RuntimeException("DISPATCHER expects a NetworkDispatcher");
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:FMLOutboundHandler.java
示例5: fireNetworkHandshake
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
/**
* INTERNAL fire a handshake to all channels
* @param networkDispatcher The dispatcher firing
* @param origin which side the dispatcher is on
*/
public void fireNetworkHandshake(NetworkDispatcher networkDispatcher, Side origin)
{
NetworkHandshakeEstablished handshake = new NetworkHandshakeEstablished(networkDispatcher, networkDispatcher.getNetHandler(), origin);
for (Entry<String, FMLEmbeddedChannel> channel : channels.get(origin).entrySet())
{
channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.DISPATCHER);
channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(networkDispatcher);
channel.getValue().pipeline().fireUserEventTriggered(handshake);
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:16,代码来源:NetworkRegistry.java
示例6: userEventTriggered
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的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: initLiason
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
private void initLiason() {
// We're fairly similar to PacketProxyingPlayer.initWrapping()
networkManager = new CustomChannelNetworkManager(proxiedChannel, EnumPacketDirection.SERVERBOUND);
this.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), networkManager, this);
playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).set(new NetworkDispatcher(networkManager));
//Compare net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget.PLAYER.{...}.selectNetworks(Object, ChannelHandlerContext, FMLProxyPacket)
playerNetServerHandler.netManager.setConnectionState(EnumConnectionState.PLAY);
}
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:9,代码来源:InteractionLiason.java
示例8: preinitWrapping
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
void preinitWrapping() {
playerNetServerHandler = new NetHandlerPlayServer(mcServer, networkManager, this);
playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).set(new NetworkDispatcher(this.networkManager));
//Compare net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget.PLAYER.{...}.selectNetworks(Object, ChannelHandlerContext, FMLProxyPacket)
playerNetServerHandler.netManager.setConnectionState(EnumConnectionState.PLAY);
/* (misc notes here)
* We don't need to touch NetworkDispatcher; we need a NetworkManager.
*
* NetworkManager.scheduleOutboundPacket is too early I think?
* What we really want is its channel.
*/
}
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:13,代码来源:PacketProxyingPlayer.java
示例9: queueUnwrappedPacket
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public boolean queueUnwrappedPacket(EntityPlayer player, Object packetObj) {
if (packetObj == null) return true;
if (player == null) {
if (packetObj instanceof C00PacketKeepAlive || packetObj instanceof S00PacketKeepAlive) {
NORELEASE.fixme("Shouldn't this, like, not happen?");
return true;
}
NORELEASE.println("No player to handle: " + packetObj + " " + packetObj.getClass().getSimpleName());
return true;
}
if (player.worldObj.isRemote) return false;
Packet packet = (Packet) packetObj;
// May possibly need to inject the liason into things up higher, during reading. Somehow. Hopefulloy won't be needed.
InteractionLiason liason = InteractionLiason.activeLiasons.get(player);
if (liason == null) {
if (!(packet instanceof C00PacketKeepAlive)) {
// Seems our system isn't perfect. :/
// Keepalives are generated from a different thread I guess.
Hammer.logWarning("Liasonless wrapped packet: " + packet.getClass().getSimpleName() + " " + packet.toString());
}
return true;
}
NetHandlerPlayServer handler = liason.playerNetServerHandler;
if (packet instanceof FMLProxyPacket) {
FMLProxyPacket fml = (FMLProxyPacket) packet;
NetworkDispatcher dispatcher = handler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
fml.setTarget(Side.CLIENT);
fml.setDispatcher(dispatcher);
if (fml.payload().readerIndex() != 0) {
Core.logSevere("Packet double-processing detected! Channel: " + fml.channel());
return true;
}
}
packet.processPacket(handler);
return true;
}
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:37,代码来源:HammerProxy.java
示例10: listDispatchers
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public void listDispatchers(Collection<EntityPlayerMP> players, Collection<NetworkDispatcher> result) {
for (EntityPlayerMP player : players) {
NetworkDispatcher dispatcher = NetUtils.getPlayerDispatcher(player);
if (dispatcher != null) result.add(dispatcher);
else Log.info("Trying to send message to disconnected player %s", player);
}
}
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:9,代码来源:SelectMultiplePlayers.java
示例11: listDispatchers
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public void listDispatchers(DimCoord coord, Collection<NetworkDispatcher> result) {
WorldServer server = DimensionManager.getWorld(coord.dimension);
Set<EntityPlayerMP> players = NetUtils.getPlayersWatchingBlock(server, coord.blockPos.getX(), coord.blockPos.getZ());
for (EntityPlayerMP player : players) {
NetworkDispatcher dispatcher = NetUtils.getPlayerDispatcher(player);
result.add(dispatcher);
}
}
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:12,代码来源:SelectChunkWatchers.java
示例12: listDispatchers
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public void listDispatchers(Entity entity, Collection<NetworkDispatcher> result) {
Preconditions.checkArgument(entity.world instanceof WorldServer, "Invalid side");
WorldServer server = (WorldServer)entity.world;
Set<EntityPlayerMP> players = NetUtils.getPlayersWatchingEntity(server, entity);
for (EntityPlayerMP player : players) {
NetworkDispatcher dispatcher = NetUtils.getPlayerDispatcher(player);
result.add(dispatcher);
}
}
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:12,代码来源:SelectEntityWatchers.java
示例13: write
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的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
示例14: NetworkHandshakeEstablished
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public NetworkHandshakeEstablished(NetworkDispatcher dispatcher, INetHandler netHandler, Side origin)
{
this.netHandler = netHandler;
this.dispatcher = dispatcher;
this.side = origin;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:NetworkHandshakeEstablished.java
示例15: setDispatcher
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public void setDispatcher(NetworkDispatcher networkDispatcher)
{
this.dispatcher = networkDispatcher;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:FMLProxyPacket.java
示例16: getDispatcher
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public NetworkDispatcher getDispatcher()
{
return this.dispatcher;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:FMLProxyPacket.java
示例17: channelRead0
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, CompleteHandshake msg) throws Exception
{
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove();
dispatcher.completeHandshake(msg.target);
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:HandshakeCompletionHandler.java
示例18: fmlServerHandshake
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public static void fmlServerHandshake(PlayerList scm, NetworkManager manager, EntityPlayerMP player)
{
NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(manager, scm);
dispatcher.serverToClientHandshake(player);
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:FMLNetworkHandler.java
示例19: fmlClientHandshake
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public static void fmlClientHandshake(NetworkManager networkManager)
{
NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(networkManager);
dispatcher.clientToServerHandshake();
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:FMLNetworkHandler.java
示例20: write
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
if (!(msg instanceof FMLProxyPacket))
{
return;
}
FMLProxyPacket pkt = (FMLProxyPacket) msg;
OutboundTarget outboundTarget;
Object args = null;
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
// INTERNAL message callback - let it pass out
if (dispatcher != null)
{
ctx.write(msg, promise);
return;
}
outboundTarget = ctx.channel().attr(FML_MESSAGETARGET).get();
Side channelSide = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();
if (outboundTarget != null && outboundTarget.allowed.contains(channelSide))
{
args = ctx.channel().attr(FML_MESSAGETARGETARGS).get();
outboundTarget.validateArgs(args);
}
else if (channelSide == Side.CLIENT)
{
outboundTarget = OutboundTarget.TOSERVER;
}
else
{
throw new FMLNetworkException("Packet arrived at the outbound handler without a valid target!");
}
List<NetworkDispatcher> dispatchers = outboundTarget.selectNetworks(args, ctx, pkt);
// This will drop the messages into the output queue at the embedded channel
if (dispatchers == null)
{
ctx.write(msg, promise);
return;
}
for (NetworkDispatcher targetDispatcher : dispatchers)
{
targetDispatcher.sendProxy((FMLProxyPacket) msg);
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:48,代码来源:FMLOutboundHandler.java
注:本文中的net.minecraftforge.fml.common.network.handshake.NetworkDispatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论