本文整理汇总了Java中net.minecraftforge.fml.common.network.handshake.NetworkDispatcher类的典型用法代码示例。如果您正苦于以下问题:Java NetworkDispatcher类的具体用法?Java NetworkDispatcher怎么用?Java NetworkDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkDispatcher类属于net.minecraftforge.fml.common.network.handshake包,在下文中一共展示了NetworkDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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;
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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.
*/
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例15: setDispatcher
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; //导入依赖的package包/类
public void setDispatcher(NetworkDispatcher networkDispatcher)
{
this.dispatcher = networkDispatcher;
}