Skip to content

Commit

Permalink
Fix some smaller issues with registry sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Mar 23, 2024
1 parent 76368b9 commit b32ec56
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build-logic/src/main/java/qsl/internal/Versions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class Versions {
/**
* The QSL version
*/
public static final String QSL_VERSION = "7.0.0-alpha.11";
public static final String QSL_VERSION = "7.0.0-alpha.12";

/**
* The target Minecraft version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static void handlePacket(MinecraftClient client, ClientConfigurationNetw
receiveSlicedPacket(buf);

if (isPacketFinished) {
applyRegistry(handler);
applyRegistry(handler, sender);
}
}

Expand Down Expand Up @@ -158,8 +158,7 @@ private static void computeBufSize(PacketByteBuf buf) {
}
}

@SuppressWarnings("unchecked")
private static void applyRegistry(ClientConfigurationNetworkHandler handler) {
private static void applyRegistry(ClientConfigurationNetworkHandler handler, PacketSender<CustomPayload> sender) {
Preconditions.checkState(isPacketFinished);
Map<Identifier, Object2IntMap<Identifier>> map = syncedRegistryMap;
isPacketFinished = false;
Expand All @@ -178,7 +177,7 @@ private static void applyRegistry(ClientConfigurationNetworkHandler handler) {

var missingEntries = currentRegistry.quilt$applySyncMap(syncMap);

if (ClientRegistrySync.checkMissingAndDisconnect(handler, registry.getKey().getValue(), missingEntries, null)) { // TODO: no null
if (ClientRegistrySync.checkMissingAndDisconnect(handler, registry.getKey().getValue(), missingEntries, sender)) {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ public record SetupSyncTask(ServerConfigurationPacketHandler handler) implements

@Override
public void start(Consumer<Packet<?>> task) {
if (ServerRegistrySync.shouldSync()) {
if (!((AbstractServerPacketHandlerAccessor) this.handler).invokeIsHost() && ServerRegistrySync.shouldSync()) {
// First check if Quilt sync is available
if (ServerConfigurationNetworking.getSendable(this.handler).contains(ServerPackets.Handshake.ID)) {
((ServerConfigurationTaskManager) this.handler).addImmediateTask(new QuiltSyncTask(this.handler, ((AbstractServerPacketHandlerAccessor) this.handler).getConnection()));
} else if (ServerRegistrySync.forceFabricFallback || (ServerRegistrySync.supportFabric && ServerConfigurationNetworking.getSendable(this.handler).contains(ServerFabricRegistrySync.ID))) {
// TODO: If the client says that it supports fabric sync but then doesnt respond, the client will sit in an idle loop forever.
FabricSyncTask fabricSyncTask = new FabricSyncTask(this.handler);
ServerConfigurationNetworking.registerReceiver(this.handler, ServerFabricRegistrySync.SYNC_COMPLETE_ID, (server, handler, buf, responseSender) -> fabricSyncTask.handleComplete());
((ServerConfigurationTaskManager) this.handler).addImmediateTask(fabricSyncTask);
} else {
((AbstractServerPacketHandlerAccessor) this.handler).getConnection().disconnect(ServerRegistrySync.noRegistrySyncMessage);
if (ServerRegistrySync.requiresSync()) {
((AbstractServerPacketHandlerAccessor) this.handler).getConnection().disconnect(ServerRegistrySync.noRegistrySyncMessage);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;

import net.minecraft.network.ClientConnection;
import net.minecraft.network.listener.AbstractServerPacketHandler;
Expand All @@ -26,4 +27,7 @@
public interface AbstractServerPacketHandlerAccessor {
@Accessor
ClientConnection getConnection();

@Invoker
boolean invokeIsHost();
}

0 comments on commit b32ec56

Please sign in to comment.