@SubscribeEvent public void packetToServer(FMLNetworkEvent.ServerCustomPacketEvent event) { ByteBuf buf = event.packet.payload(); byte kind = buf.readByte(); NetHandlerPlayServer handler = (NetHandlerPlayServer) event.handler; EntityPlayerMP player = handler.playerEntity; if (kind == INTERACT_HIT || kind == INTERACT_USE) { Coord at = readCoord(buf, player); EnumFacing side = readSide(buf); if (!at.blockExists()) return; double reachSq = 6 * 6; // FIXME: There's no way to get this properly on the server? if (at.distanceSq(player) > reachSq) { log("Ignoring distant interaction packet for " + at + " from " + player); return; } FlatFace face = Flat.get(at, side); if (kind == INTERACT_HIT) { face.onHit(at, side, player); } else { face.onActivate(at, side, player); } } else { log("Invalid packet ID " + kind + " from " + player); } }
@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.getHandler(); if (handler instanceof NetHandlerPlayServer) { EntityPlayerMP entity = ((NetHandlerPlayServer)handler).playerEntity; playersJoined.add(entity.getUniqueID()); } }
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; MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name())); }
@SubscribeEvent public void onPlayerJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent e) { if (e.isLocal()) { singlePlayerGames++; ConcurrentUtil.executor.execute(() -> DiscordCE.client.getAccountManager().setGame("Minecraft [SP]")); } else { multiplayerGames++; ConcurrentUtil.executor.execute(() -> DiscordCE.client.getAccountManager().setGame("Minecraft [MP]")); } }
@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); }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { ProjectHelper.projectParts.clear(); ProjectHelper.projectTextureParts.clear(); for(ProjectInfo proj : ProjectHelper.projects.values()) { proj.destroy(); } for(Integer id : ProjectHelper.projectTextureIDs.values()) { TextureUtil.deleteTexture(id); } ProjectHelper.projects.clear(); ProjectHelper.projectTextures.clear(); ProjectHelper.projectTextureIDs.clear(); }
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { Hats.eventHandlerClient.hats.clear(); Hats.eventHandlerClient.mobHats.clear(); Hats.eventHandlerClient.playerWornHats.clear(); Hats.eventHandlerClient.requestedHats.clear(); if(Hats.eventHandlerClient.guiHatUnlocked != null) { Hats.eventHandlerClient.guiHatUnlocked.hatList.clear(); } if(Hats.eventHandlerClient.guiNewTradeReq != null) { Hats.eventHandlerClient.guiNewTradeReq.hatList.clear(); } Hats.eventHandlerClient.worldInstance = null; }
@Override public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side) { if (side == Side.CLIENT) { 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)); } }
private synchronized 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; MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager)); if (DEBUG_HANDSHAKE) manager.closeChannel(new TextComponentString("Handshake Complete review log file for details.")); scm.initializeConnectionToPlayer(manager, player, serverHandler); }
@Override public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (side == Side.CLIENT) { MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); } else { MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); } cleanAttributes(ctx); ctx.disconnect(promise); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (side == Side.CLIENT) { MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); } else { MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); } cleanAttributes(ctx); ctx.close(promise); }
@SubscribeEvent public void onDisconnect(FMLNetworkEvent.ServerDisconnectionFromClientEvent event) { INetHandlerPlayServer handlerServer = event.getHandler(); if(handlerServer instanceof NetHandlerPlayServer) { purgeSelection(((NetHandlerPlayServer) handlerServer).player); } }
@SubscribeEvent public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event) { exploTime.clear(); dismemberTimeout.clear(); explosionSources.clear(); }
/** * Prints server connection info when the client connects to a server. * <p> * Test for this thread: * http://www.minecraftforge.net/forum/index.php/topic,34546.0.html * * @param event The event */ @SideOnly(Side.CLIENT) @SubscribeEvent public void clientConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { final IThreadListener mainThread = Minecraft.getMinecraft(); mainThread.addScheduledTask(() -> { final ServerData serverData = Minecraft.getMinecraft().getCurrentServerData(); Logger.info("Server Connected! Local? %s - Address: %s", event.isLocal(), serverData != null ? serverData.serverIP : "<No ServerData>"); }); }
@SubscribeEvent @SuppressWarnings("unused") public void onClientDisconnectFromServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { EntityPlayer player = ManeuverGear.proxy.getClientPlayer(); if(player == null) { return; } unEquipGear(player); }
/** * This is used to clear out the server configuration on the client side. * @param event The event object. */ @SubscribeEvent public static void OnClientDisconnectEvent(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { // When the player logs out, make sure to re-set the server configuration. // This is so a new configuration can be successfully loaded when they switch servers or worlds (on single player. ((ClientProxy)Prefab.proxy).serverConfiguration = null; ClientEventHandler.playerConfig.clearNonPersistedObjects(); }
@SubscribeEvent public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent e) { for (String ip : ConfigHandler.spongeServers) { if (Minecraft.getMinecraft().getCurrentServerData().serverIP.contains(ip)) { JEIButtons.isSpongePresent = true; JEIButtons.logInfo("Sponge support is enabled for this server!"); break; } } }
public static void setup(FMLNetworkEvent event, Side side) { PacketJunction handler = new PacketJunction(side); Channel channel = event.manager.channel(); ChannelPipeline pipeline = channel.pipeline(); if (pipeline.get("fzds:packetJunction") == null) { pipeline.addAfter("fml:packet_handler", "fzds:packetJunction", handler); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void addBlockUndo(FMLNetworkEvent.ClientCustomPacketEvent event) { PlacedBlock at = PlacedBlock.read(event.packet.payload()); EntityPlayer player = Minecraft.getMinecraft().thePlayer; markPlacement(player, at); }
@SubscribeEvent public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { Blocksteps.eventHandler.targetAngleX = Blocksteps.eventHandler.prevAngleX = Blocksteps.eventHandler.angleX = Blocksteps.config.camStartVertical; Blocksteps.eventHandler.targetAngleY = Blocksteps.eventHandler.prevAngleY = Blocksteps.eventHandler.angleY = Blocksteps.eventHandler.oriAngleY = Blocksteps.config.camStartHorizontal; Blocksteps.eventHandler.targetScale = Blocksteps.config.camStartScale; Blocksteps.eventHandler.prevScale = Blocksteps.eventHandler.scale = 0; saveTimeout = Blocksteps.config.saveInterval; String connectionName = event.getManager().getRemoteAddress().toString(); if(connectionName.contains("/") && !connectionName.startsWith("/192.168.")) //probably a public server { saveLocation = new File(new File(ResourceHelper.getModsFolder(), "/blocksteps/"), connectionName.substring(0, connectionName.indexOf("/")) + "_" + connectionName.substring(connectionName.indexOf(":") + 1, connectionName.length()) + ".bsv"); if(saveLocation.exists()) { try { byte[] data = new byte[(int)saveLocation.length()]; FileInputStream stream = new FileInputStream(saveLocation); stream.read(data); stream.close(); MapSaveFile save = (new Gson()).fromJson(IOUtil.decompress(data), MapSaveFile.class); save.load(); } catch(Exception e) { Blocksteps.LOGGER.warn("Error loading save file: " + saveLocation); }; } } else if(connectionName.startsWith("local") || connectionName.startsWith("/192.168.")) { attemptLocalLoad = true; } }
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { if(renderGlobalProxy != null && renderGlobalProxy.theWorld != null) { if(saveLocation != null) { saveLocation.getParentFile().mkdirs(); try { FileOutputStream stream = new FileOutputStream(saveLocation); stream.write(IOUtil.compress((new Gson()).toJson(MapSaveFile.create()))); stream.close(); } catch(Exception e) { Blocksteps.LOGGER.warn("Error saving file: " + saveLocation); } saveLocation = null; } setNewWorld(null); steps.clear(); blocksToRenderByStep.clear(); ChunkStore.clear(); synchronized(Blocksteps.eventHandler.threadCheckBlocks.checks) { Blocksteps.eventHandler.threadCheckBlocks.checks.clear(); } } }
@SubscribeEvent public void onClientConnectToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { if (SprinklesForVanilla.isOnServer) { //SprinklesForVanilla.network.sendToServer(new ConfigPacket("","")); LogHelper.info("Client has Joined Server with sprinkles_for_vanilla"); } }
@SubscribeEvent public static void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { if (!event.isLocal()) { // Disable server specific options, which will be re-enabled if the server replies LogHandler.info("CLIENT: Connected to server. Disabling server-side click actions until server replies"); ActionSessionData.activateClientValues(); } else { ActionSessionData.activateAll(); } }
@SubscribeEvent public void onServerPacket(final FMLNetworkEvent.ServerCustomPacketEvent event) { final AbstractMBPacket packet = map.get(event.getPacket().channel()); if (packet != null) { Battlegear.proxy.getThreadListener().addScheduledTask(new Runnable() { @Override public void run() { packet.process(event.getPacket().payload(), ((NetHandlerPlayServer) event.getHandler()).player); } }); } }
@SubscribeEvent public void onClientPacket(final FMLNetworkEvent.ClientCustomPacketEvent event) { final AbstractMBPacket packet = map.get(event.getPacket().channel()); if (packet != null) { Battlegear.proxy.getThreadListener().addScheduledTask(new Runnable() { @Override public void run() { packet.process(event.getPacket().payload(), Battlegear.proxy.getClientPlayer()); } }); } }
@SubscribeEvent public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { Hats.eventHandlerClient.isActive = true; SessionState.serverHasMod = 0; SessionState.currentKing = ""; SessionState.showJoinMessage = 0; SessionState.hasVisited = 1; HatHandler.repopulateHatsList(); }
@SubscribeEvent public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event) { connectingToServer = true; if(iChunUtil.userIsPatron) { patronUpdateServerAsPatron = true; } for(ConfigBase conf : ConfigHandler.configs) { conf.storeSession(); } }
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { IThreadListener thread = Minecraft.getMinecraft(); if(thread.isCallingFromMinecraftThread()) { onClientDisconnect(); } else { thread.addScheduledTask(this::onClientDisconnect); } }
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { Minecraft.getMinecraft().addScheduledTask(this::disconnectFromServer); }
@SubscribeEvent public void serverLoginEvent(FMLNetworkEvent.ClientConnectedToServerEvent event) { hasJoinedWorld = false; }
@SubscribeEvent public void clientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent evt) { CreeperHost.instance.curServerId = -1; }
@SubscribeEvent public void onConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { getOrSetPublicLog(); // set public log file }
@SubscribeEvent public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { publicLog = null; }
@SubscribeEvent public static void onLogin(FMLNetworkEvent.ClientConnectedToServerEvent event) { executorService.scheduleAtFixedRate(new TCCheck(CHANNEL), 5, DELAY, TimeUnit.SECONDS); System.out.println("The thread is now running"); }
@SubscribeEvent public static void onLogout(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { executorService.shutdown(); }
@SubscribeEvent public static void disconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { SolarApi.getRelativityPowerMap().clear(); SolarApi.getRelativityMap().clear(); SolarApi.setQuantumData(null); }
@SideOnly(Side.CLIENT) @SubscribeEvent public void clientConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { Minecraft.getMinecraft().addScheduledTask(() -> MinecraftForge.EVENT_BUS.register(EntityEventHandler.INSTANCE)); }
@SubscribeEvent public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { onClientConnection(); }
@SubscribeEvent public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { onClientConnection(); }