use of net.minecraft.network.Connection in project MinecraftForge by MinecraftForge.
the class HandshakeHandler method handleRegistryLoading.
private boolean handleRegistryLoading(final Supplier<NetworkEvent.Context> contextSupplier) {
// We use a countdown latch to suspend the impl thread pending the client thread processing the registry data
AtomicBoolean successfulConnection = new AtomicBoolean(false);
CountDownLatch block = new CountDownLatch(1);
contextSupplier.get().enqueueWork(() -> {
LOGGER.debug(FMLHSMARKER, "Injecting registry snapshot from server.");
final Multimap<ResourceLocation, ResourceLocation> missingData = GameData.injectSnapshot(registrySnapshots, false, false);
LOGGER.debug(FMLHSMARKER, "Snapshot injected.");
if (!missingData.isEmpty()) {
LOGGER.error(FMLHSMARKER, "Missing registry data for impl connection:\n{}", LogMessageAdapter.adapt(sb -> missingData.forEach((reg, entry) -> sb.append("\t").append(reg).append(": ").append(entry).append('\n'))));
}
successfulConnection.set(missingData.isEmpty());
block.countDown();
});
LOGGER.debug(FMLHSMARKER, "Waiting for registries to load.");
try {
block.await();
} catch (InterruptedException e) {
Thread.interrupted();
}
if (successfulConnection.get()) {
LOGGER.debug(FMLHSMARKER, "Registry load complete, continuing handshake.");
} else {
LOGGER.error(FMLHSMARKER, "Failed to load registry, closing connection.");
this.manager.disconnect(new TextComponent("Failed to synchronize registry data from server, closing connection"));
}
return successfulConnection.get();
}
Aggregations