Posted August 30, 20232 yr well I can get the port @SubscribeEvent public static void validServerIpCheck(FMLServerAboutToStartEvent event) { if (event.getServer().getPort() == 20191) { event.getServer().close(); } } but I want to get the ip adress actually so how?
August 30, 20232 yr In general, there is really no such thing. In the default configuration, minecraft binds to the "Any" address which means it will bind to all ip addresses the machine has. If you run the command "netstat -an" on the command line you can see examples of these, e.g. something like this for ipv4 or ipv6 Quote Proto Local Address Foreign Address State TCP 0.0.0.0:20191 0.0.0.0:0 LISTENING TCP [::]:20191 [::]:0 LISTENING However, if the user specified an ip address in their server.properties you can get this from server.getLocalIp() - it will be blank if it wasn't specified There is also the issue that the server might not be using TCP/IP, e.g. it could be single player (in memory) or they could be using that essentials mod that completely changes the networking. Look at ServerConnectionListener.startTcpServerListener()/startMemoryChannel() for the vanilla code. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr If you are just interested in getting the ip address of the machine. you can just the normal java api InetAddress.getLocalHost().getHostAddress() This assumes it only has one or that call returns the one you are interested in. Edited August 30, 20232 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr Author wdym by machine? does this get the ip of the server? for example: 95.216.241.230:25567
August 30, 20232 yr The computer or virtual machine (if it is hosted in the cloud) running minecraft. The answer to the rest of your question is above. in short "maybe", because in general there is no such thing. It only exists in specific configurations. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr Author you say there is no such thing but in a post you said this https://forums.minecraftforge.net/topic/123696-getting-a-raw-server-ip-address/?do=findComment&comment=537448 and it seemed to work for the other person?
August 30, 20232 yr Those are 2 different things. The first part is getting the client ip address on the server. And the last part is getting the server ip address on the client. In both cases there can be only be one unique ip address if you know it is a tcp/ip connection. It is the one the connection has been ESTABLISHED on. You want the ip address the server is LISTENING on, which could be many (the "any" address) or none (i.e. single player or some other network protocol provided by a mod). Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr Author oooh ok I see. So there is actually no possible way to get the ip basically? + why is this forum loading so damn long
August 30, 20232 yr In general no. But if you know it is TCP/IP and the machine has only one ip address, that InetAddress code above should get it. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr Author so yea, the ports are free over TCP @SubscribeEvent public static void validServerIpCheck(FMLServerAboutToStartEvent event) throws UnknownHostException { if (!InetAddress.getLocalHost().getHostAddress().equals("45.142.112.194")) { event.getServer().close(); } } so this would work?
August 30, 20232 yr Author rip the server crashes here is the crash report: https://pastebin.com/nHNGgkRd
August 30, 20232 yr Minecraft 1.16 is no longer supported in this forum. https://forums.minecraftforge.net/topic/91712-supported-version-directory/ But you should read the docs on that event: https://github.com/MinecraftForge/MinecraftForge/blob/e69f5e262ac6481ca35e181b1720e99bc50320fe/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java#L11 You are closing the server long before it has even started loading the server (hence the NPE). It has only just finished loading mods. Closing the server will terminate it anyway. Edited August 30, 20232 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 30, 20232 yr Author i dont think thats the problem because I did the same thing with the port and it worked there, changed the port to random port and it closed the server.
August 30, 20232 yr Author so I used FMLServerStartedEvent and still crashing: https://gnomebot.dev/paste/1146573199082008616 Edited August 30, 20232 yr by jaxox
August 30, 20232 yr Hint: Look at the StopCommand and its use of server.halt() Since you are using 1.16 they might not be called that? But that's it. I am not giving anymore support for that version. You need to be using a modern supported version of minecraft to get help in this forum. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.