24
24
import com .falsepattern .lib .internal .Share ;
25
25
import lombok .val ;
26
26
27
+ import net .minecraft .client .Minecraft ;
28
+ import net .minecraft .entity .player .EntityPlayerMP ;
29
+ import cpw .mods .fml .common .FMLCommonHandler ;
27
30
import cpw .mods .fml .common .network .simpleimpl .IMessage ;
28
31
import cpw .mods .fml .common .network .simpleimpl .IMessageHandler ;
29
32
import cpw .mods .fml .common .network .simpleimpl .MessageContext ;
30
33
import cpw .mods .fml .relauncher .Side ;
31
34
32
35
import java .io .IOException ;
36
+ import java .util .Objects ;
33
37
34
38
public class SyncRequestHandler implements IMessageHandler <SyncRequest , IMessage > {
35
39
@ Override
@@ -38,6 +42,12 @@ public IMessage onMessage(SyncRequest message, MessageContext ctx) {
38
42
//Do not sync client to server
39
43
return null ;
40
44
}
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
+ }
41
51
try {
42
52
message .receive ();
43
53
val reply = new SyncReply ();
@@ -50,4 +60,13 @@ public IMessage onMessage(SyncRequest message, MessageContext ctx) {
50
60
return null ;
51
61
}
52
62
}
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
+ }
53
72
}
0 commit comments