Get player's current server
CommandCracker8 opened this issue ยท 3 comments
How can I get the current server IP and/or world name the player is currently on?
I assume you are trying to do this programmatically?
Using logic similar to Vanilla's MinecraftClient.getWindowTitle()
ServerInfo info = MinecraftClient.getCurrentServerEntry();
which has a name and address when not null.
Or you use the network information;
ClientConnection clientConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection();
If this is not null you can getAddress()
.
If it is a remote server the address should be castable to a java.net.InetSocketAddress