2424import com .falsepattern .lib .internal .Share ;
2525import lombok .val ;
2626
27+ import net .minecraft .client .Minecraft ;
28+ import net .minecraft .entity .player .EntityPlayerMP ;
29+ import cpw .mods .fml .common .FMLCommonHandler ;
2730import cpw .mods .fml .common .network .simpleimpl .IMessage ;
2831import cpw .mods .fml .common .network .simpleimpl .IMessageHandler ;
2932import cpw .mods .fml .common .network .simpleimpl .MessageContext ;
3033import cpw .mods .fml .relauncher .Side ;
3134
3235import java .io .IOException ;
36+ import java .util .Objects ;
3337
3438public class SyncRequestHandler implements IMessageHandler <SyncRequest , IMessage > {
3539 @ Override
@@ -38,6 +42,12 @@ public IMessage onMessage(SyncRequest message, MessageContext ctx) {
3842 //Do not sync client to server
3943 return null ;
4044 }
45+ if (Objects .requireNonNull (FMLCommonHandler .instance ().getSide ()) == Side .CLIENT ) {
46+ //Integrated server only syncs to open-to-lan joiners
47+ if (isLocalPlayer (ctx .getServerHandler ().playerEntity )) {
48+ return null ;
49+ }
50+ }
4151 try {
4252 message .receive ();
4353 val reply = new SyncReply ();
@@ -50,4 +60,13 @@ public IMessage onMessage(SyncRequest message, MessageContext ctx) {
5060 return null ;
5161 }
5262 }
63+
64+ private static boolean isLocalPlayer (EntityPlayerMP playerMP ) {
65+ val localPlayer = Minecraft .getMinecraft ().thePlayer ;
66+ if (localPlayer == null )
67+ return false ;
68+ val remoteUUID = playerMP .getUniqueID ();
69+ val localUUID = localPlayer .getUniqueID ();
70+ return Objects .equals (remoteUUID , localUUID );
71+ }
5372}
0 commit comments