本文整理汇总了Java中cpw.mods.fml.common.network.FMLNetworkEvent类的典型用法代码示例。如果您正苦于以下问题:Java FMLNetworkEvent类的具体用法?Java FMLNetworkEvent怎么用?Java FMLNetworkEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FMLNetworkEvent类属于cpw.mods.fml.common.network包,在下文中一共展示了FMLNetworkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clientConnectedtoServer
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
if (!CreeperHost.instance.active)
return;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
return;
INetHandlerPlayServer handler = event.handler;
if (handler instanceof NetHandlerPlayServer)
{
EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity;
playersJoined.add(entity.getUniqueID());
}
}
示例2: connectionOpened
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void connectionOpened( FMLNetworkEvent.ClientConnectedToServerEvent event )
{
if( !event.isLocal )
{
SocketAddress socketAddress = event.manager.getSocketAddress();
if( socketAddress != null && socketAddress instanceof InetSocketAddress )
{
InetSocketAddress internet = (InetSocketAddress)socketAddress;
String hostString = null;
try
{
Method getHostString = InetSocketAddress.class.getDeclaredMethod( "getHostString", new Class[]{} );
getHostString.setAccessible( true );
hostString = getHostString.invoke( internet ).toString();
}
catch( Exception e )
{
hostString = internet.getHostName();
}
QCraft.setCurrentServerAddress( hostString + ":" + internet.getPort() );
return;
}
}
QCraft.setCurrentServerAddress( null );
}
示例3: onReceiveClient
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onReceiveClient(FMLNetworkEvent.ClientCustomPacketEvent evt) {
World world = Minecraft.getMinecraft().theWorld;
EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;
try {
ByteBufInputStream in = new ByteBufInputStream(evt.packet.payload());
// Read the container
PlayBlockPayload container = new PlayBlockPayload();
container.read(in);
// Figure out what we are containing
switch (container.getType()) {
case TILE_ENTITY:
handleTilePayload(world, entityPlayer, in);
break;
case TILE_ENTITY_NBT:
handleNetworkedNBT(world, evt.packet.payload());
}
} catch (IOException e) {
PlayBlock.log(Level.WARN, "Failed to read packet data from " + entityPlayer.getDisplayName(), e);
}
}
示例4: connectionReceived
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void connectionReceived(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
if (!event.isLocal && Pay2Spawn.getConfig().forceP2S)
{
final String username = ((NetHandlerPlayServer) event.handler).playerEntity.getCommandSenderName();
new Timer().schedule(new TimerTask()
{
@Override
public void run()
{
if (!StatusMessage.doesPlayerHaveValidConfig(username)) MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(username).playerNetServerHandler.kickPlayerFromServer("Pay2Spawn is required on this server.\nIt needs to be configured properly.");
}
}, 5 * 1000);
}
}
示例5: onPacketData
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
FMLProxyPacket pkt = event.packet;
onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
示例6: fireNetRegistrationEvent
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
if (side == Side.CLIENT)
{
waitForPlayClient();
bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
}
else
{
bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
}
}
示例7: completeClientSideConnection
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeClientSideConnection(ConnectionType type)
{
this.connectionType = type;
FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
}
示例8: completeServerSideConnection
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeServerSideConnection(ConnectionType type)
{
this.connectionType = type;
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
scm.func_72355_a(manager, player, serverHandler);
}
示例9: disconnect
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
if (side == Side.CLIENT)
{
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
}
else
{
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
}
cleanAttributes(ctx);
ctx.disconnect(promise);
}
示例10: close
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
if (side == Side.CLIENT)
{
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
}
else
{
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
}
cleanAttributes(ctx);
ctx.close(promise);
}
示例11: completeServerSideConnection
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeServerSideConnection(ConnectionType type)
{
this.connectionType = type;
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
this.state = ConnectionState.CONNECTED;
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
scm.initializeConnectionToPlayer(manager, player, serverHandler);
}
示例12: onPacketData
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
FMLProxyPacket pkt = event.packet;
onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
示例13: onClientPacket
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientPacket( FMLNetworkEvent.ClientCustomPacketEvent event )
{
try
{
QCraftPacket packet = new QCraftPacket();
packet.fromBytes( event.packet.payload() );
QCraft.handleClientPacket( packet );
}
catch( Exception e )
{
// Something failed, ignore it
e.printStackTrace();
}
}
示例14: onServerPacket
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onServerPacket( FMLNetworkEvent.ServerCustomPacketEvent event )
{
try
{
QCraftPacket packet = new QCraftPacket();
packet.fromBytes( event.packet.payload() );
QCraft.handleServerPacket( packet, ((NetHandlerPlayServer)event.handler).playerEntity );
}
catch( Exception e )
{
// Something failed, ignore it
e.printStackTrace();
}
}
示例15: onReceiveServer
import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onReceiveServer(FMLNetworkEvent.ServerCustomPacketEvent evt) {
EntityPlayer entityPlayer = ((NetHandlerPlayServer) evt.handler).playerEntity;
World world;
// Get the world
if (entityPlayer != null) {
world = entityPlayer.worldObj;
} else {
PlayBlock.log(Level.WARN, "Received an update packet from an invalid player!");
return;
}
try {
ByteBufInputStream in = new ByteBufInputStream(evt.packet.payload());
// Read the container
PlayBlockPayload container = new PlayBlockPayload();
container.read(in);
// Figure out what we are containing
switch (container.getType()) {
case TILE_ENTITY:
handleTilePayload(world, entityPlayer, in);
break;
case TILE_ENTITY_NBT:
handleNetworkedNBT(world, evt.packet.payload());
}
} catch (IOException e) {
PlayBlock.log(Level.WARN, "Failed to read packet data from " + entityPlayer.getDisplayName(), e);
}
}