Skip to content

Commit 7061419

Browse files
committed
fix config synchronization
1 parent b1df7dc commit 7061419

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/main/java/com/falsepattern/lib/internal/impl/config/ConfigurationManagerImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ public static void sendReply(DataOutput output, List<Class<?>> requestedClasses)
161161
}
162162

163163
public static void receiveReply(DataInput input) throws IOException {
164-
if (!AllConfigSyncEvent.postStart()) {
165-
Share.LOG.warn("Config synchronization was cancelled by event.");
164+
if (AllConfigSyncEvent.postStart()) {
165+
Share.LOG.warn("All config synchronization was cancelled by event.");
166+
return;
166167
}
167168
int count = input.readInt();
168169
for (int i = 0; i < count; i++) {
@@ -182,7 +183,7 @@ public static void receiveReply(DataInput input) throws IOException {
182183
+ serializedName);
183184
continue;
184185
}
185-
if (!ConfigSyncEvent.postStart(clazz)) {
186+
if (ConfigSyncEvent.postStart(clazz)) {
186187
input.skipBytes(dataSize);
187188
Share.LOG.warn("Config synchronization was cancelled by event for: " + serializedName);
188189
continue;

src/main/java/com/falsepattern/lib/internal/impl/config/net/SyncRequestHandler.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
import com.falsepattern.lib.internal.Share;
2525
import lombok.val;
2626

27+
import net.minecraft.client.Minecraft;
28+
import net.minecraft.entity.player.EntityPlayerMP;
29+
import cpw.mods.fml.common.FMLCommonHandler;
2730
import cpw.mods.fml.common.network.simpleimpl.IMessage;
2831
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
2932
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
3033
import cpw.mods.fml.relauncher.Side;
3134

3235
import java.io.IOException;
36+
import java.util.Objects;
3337

3438
public 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

Comments
 (0)