cpw.mods.fml.common.network.FMLNetworkEvent Java Examples
The following examples show how to use
cpw.mods.fml.common.network.FMLNetworkEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionHandler.java From qcraft-mod with Apache License 2.0 | 6 votes |
@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 ); }
Example #2
Source File: PacketHandler.java From qcraft-mod with Apache License 2.0 | 5 votes |
@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(); } }
Example #3
Source File: PacketHandler.java From qcraft-mod with Apache License 2.0 | 5 votes |
@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(); } }
Example #4
Source File: MwForge.java From mapwriter with MIT License | 5 votes |
@SubscribeEvent public void onConnected(FMLNetworkEvent.ClientConnectedToServerEvent event){ if (!event.isLocal) { InetSocketAddress address = (InetSocketAddress) event.manager.getSocketAddress(); Mw.instance.setServerDetails(address.getHostName(), address.getPort()); } }
Example #5
Source File: Events.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onPlayerJoinedServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { UltimateLogger.INSTANCE.sendServerConnectInfo(); }
Example #6
Source File: ClientHandler.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void onDc(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { EffectHandler.getInstance().clear(); RenderTileEssentiaCompressor.ownedVortex.clear(); }
Example #7
Source File: ConnectionHandler.java From qcraft-mod with Apache License 2.0 | 4 votes |
@SubscribeEvent public void connectionClosed( FMLNetworkEvent.ClientDisconnectionFromServerEvent event ) { QCraft.setCurrentServerAddress( null ); }