mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-11 17:17:32 +00:00
fix config synchronization
This commit is contained in:
2 files changed
+23
-3
No files matched your search
+4
-3
@@ -161,8 +161,9 @@ public final class ConfigurationManagerImpl {
|
||||
}
|
||||
|
||||
public static void receiveReply(DataInput input) throws IOException {
|
||||
if (!AllConfigSyncEvent.postStart()) {
|
||||
Share.LOG.warn("Config synchronization was cancelled by event.");
|
||||
if (AllConfigSyncEvent.postStart()) {
|
||||
Share.LOG.warn("All config synchronization was cancelled by event.");
|
||||
return;
|
||||
}
|
||||
int count = input.readInt();
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -182,7 +183,7 @@ public final class ConfigurationManagerImpl {
|
||||
+ serializedName);
|
||||
continue;
|
||||
}
|
||||
if (!ConfigSyncEvent.postStart(clazz)) {
|
||||
if (ConfigSyncEvent.postStart(clazz)) {
|
||||
input.skipBytes(dataSize);
|
||||
Share.LOG.warn("Config synchronization was cancelled by event for: " + serializedName);
|
||||
continue;
|
||||
|
||||
@@ -24,12 +24,16 @@ import com.falsepattern.lib.internal.FalsePatternLib;
|
||||
import com.falsepattern.lib.internal.Share;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SyncRequestHandler implements IMessageHandler<SyncRequest, IMessage> {
|
||||
@Override
|
||||
@@ -38,6 +42,12 @@ public class SyncRequestHandler implements IMessageHandler<SyncRequest, IMessage
|
||||
//Do not sync client to server
|
||||
return null;
|
||||
}
|
||||
if (Objects.requireNonNull(FMLCommonHandler.instance().getSide()) == Side.CLIENT) {
|
||||
//Integrated server only syncs to open-to-lan joiners
|
||||
if (isLocalPlayer(ctx.getServerHandler().playerEntity)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
try {
|
||||
message.receive();
|
||||
val reply = new SyncReply();
|
||||
@@ -50,4 +60,13 @@ public class SyncRequestHandler implements IMessageHandler<SyncRequest, IMessage
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLocalPlayer(EntityPlayerMP playerMP) {
|
||||
val localPlayer = Minecraft.getMinecraft().thePlayer;
|
||||
if (localPlayer == null)
|
||||
return false;
|
||||
val remoteUUID = playerMP.getUniqueID();
|
||||
val localUUID = localPlayer.getUniqueID();
|
||||
return Objects.equals(remoteUUID, localUUID);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user