From 7ff1e60af9e2b0cc4ef741614f1f89fbd17aa2d0 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 22 Aug 2012 11:48:30 -0400 Subject: [PATCH] Fix LAN to try hard to find a real network interface, not just localhost most of the time --- .../IntegratedServerListenThread.java.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 fml/patches/minecraft/net/minecraft/src/IntegratedServerListenThread.java.patch diff --git a/fml/patches/minecraft/net/minecraft/src/IntegratedServerListenThread.java.patch b/fml/patches/minecraft/net/minecraft/src/IntegratedServerListenThread.java.patch new file mode 100644 index 000000000..4d909ffab --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/src/IntegratedServerListenThread.java.patch @@ -0,0 +1,49 @@ +--- ../src-base/minecraft/net/minecraft/src/IntegratedServerListenThread.java ++++ ../src-work/minecraft/net/minecraft/src/IntegratedServerListenThread.java +@@ -4,6 +4,12 @@ + import cpw.mods.fml.common.asm.SideOnly; + import java.io.IOException; + import java.net.InetAddress; ++import java.net.NetworkInterface; ++import java.util.Collections; ++ ++import com.google.common.collect.Iterators; ++import com.google.common.collect.Lists; ++ + import net.minecraft.server.MinecraftServer; + + @SideOnly(Side.CLIENT) +@@ -48,7 +54,32 @@ + + try + { +- this.field_71757_g = new ServerListenThread(this, InetAddress.getLocalHost(), var1); ++ InetAddress add = null; ++ NetworkInterface notLocal = null; ++ for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) ++ { ++ if (!ni.isLoopback() && ni.isUp()) ++ { ++ notLocal = ni; ++ break; ++ } ++ } ++ if (notLocal != null) ++ { ++ for (InetAddress inadd : Collections.list(notLocal.getInetAddresses())) ++ { ++ if (inadd.getAddress().length == 4) ++ { ++ add = inadd; ++ break; ++ } ++ } ++ } ++ if (add == null) ++ { ++ add = InetAddress.getLocalHost(); ++ } ++ this.field_71757_g = new ServerListenThread(this, add, var1); + this.field_71757_g.start(); + } + catch (IOException var3)