net.minecraftforge.fml.common.network.FMLNetworkEvent Java Examples
The following examples show how to use
net.minecraftforge.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: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) @SuppressWarnings("unchecked") public void onClientPacket(FMLNetworkEvent.ClientCustomPacketEvent event) { Packet packet = proxy2packet(event.getPacket()); if (clientExecutors.containsKey(packet.getClass())) { PacketExecutor<Packet, NetHandlerPlayClient> executor = (PacketExecutor<Packet, NetHandlerPlayClient>) clientExecutors.get(packet.getClass()); NetHandlerPlayClient handler = (NetHandlerPlayClient) event.getHandler(); IThreadListener threadListener = FMLCommonHandler.instance().getWorldThread(handler); if(threadListener.isCallingFromMinecraftThread()) { executor.execute(packet, handler); } else { threadListener.addScheduledTask(() -> executor.execute(packet, handler)); } } }
Example #2
Source File: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent @SuppressWarnings("unchecked") public void onServerPacket(FMLNetworkEvent.ServerCustomPacketEvent event) { Packet packet = proxy2packet(event.getPacket()); if (serverExecutors.containsKey(packet.getClass())) { PacketExecutor<Packet, NetHandlerPlayServer> executor = (PacketExecutor<Packet, NetHandlerPlayServer>) serverExecutors.get(packet.getClass()); NetHandlerPlayServer handler = (NetHandlerPlayServer) event.getHandler(); IThreadListener threadListener = FMLCommonHandler.instance().getWorldThread(handler); if(threadListener.isCallingFromMinecraftThread()) { executor.execute(packet, handler); } else { threadListener.addScheduledTask(() -> executor.execute(packet, handler)); } } }
Example #3
Source File: NetworkListener.java From SkyblockAddons with MIT License | 4 votes |
@SubscribeEvent public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { // Leave Skyblock when the player disconnects EVENT_BUS.post(new SkyblockLeftEvent()); }
Example #4
Source File: AntiAfkMod.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { reset(); }
Example #5
Source File: ExtraInventory.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onDisconnectToServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { onDisabled(); }
Example #6
Source File: ScoreboardListenerService.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { ignore = false; }
Example #7
Source File: ScoreboardListenerService.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { ignore = false; }