diff --git a/cloud-fabric/src/main/java/org/incendo/cloud/fabric/internal/CloudFabricEntrypoint.java b/cloud-fabric/src/main/java/org/incendo/cloud/fabric/internal/CloudFabricEntrypoint.java index 7ed8bd8e..507f8c84 100644 --- a/cloud-fabric/src/main/java/org/incendo/cloud/fabric/internal/CloudFabricEntrypoint.java +++ b/cloud-fabric/src/main/java/org/incendo/cloud/fabric/internal/CloudFabricEntrypoint.java @@ -23,6 +23,7 @@ // package org.incendo.cloud.fabric.internal; +import java.util.Objects; import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; @@ -36,13 +37,21 @@ @DefaultQualifier(NonNull.class) public final class CloudFabricEntrypoint implements ModInitializer { + @SuppressWarnings("EmptyCatch") @Override public void onInitialize() { if (FabricLoader.getInstance().isModLoaded("adventure-platform-fabric")) { - ServerLifecycleEvents.SERVER_STARTING.register(AdventureSupport.get()::setupServer); - ServerLifecycleEvents.SERVER_STOPPED.register(AdventureSupport.get()::removeServer); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - AdventureSupport.get().setupClient(); + try { + Objects.requireNonNull( + Class.forName("net.kyori.adventure.platform.modcommon.MinecraftAudiences").getName() + ); + + ServerLifecycleEvents.SERVER_STARTING.register(AdventureSupport.get()::setupServer); + ServerLifecycleEvents.SERVER_STOPPED.register(AdventureSupport.get()::removeServer); + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + AdventureSupport.get().setupClient(); + } + } catch (final ClassNotFoundException ignored) { } } } diff --git a/cloud-minecraft-modded-common/build.gradle.kts b/cloud-minecraft-modded-common/build.gradle.kts index 6397f7a2..fa3f8bcc 100644 --- a/cloud-minecraft-modded-common/build.gradle.kts +++ b/cloud-minecraft-modded-common/build.gradle.kts @@ -12,6 +12,7 @@ dependencies { mappings(loom.officialMojangMappings()) compileOnly(libs.fabricLoader) + // todo: depend on common when deps fixed modCompileOnly(libs.adventureFabric) compileOnly(libs.cloud.minecraft.extras) diff --git a/cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/internal/AdventureSupport.java b/cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/internal/AdventureSupport.java index a1911e91..4ef27648 100644 --- a/cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/internal/AdventureSupport.java +++ b/cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/internal/AdventureSupport.java @@ -54,6 +54,7 @@ private void setupConverter() { try { ComponentMessageThrowableConverter.setup(this); } catch (final LinkageError ignored) { + // cloud-minecraft-extras not present } } diff --git a/cloud-neoforge/src/main/resources/META-INF/neoforge.mods.toml b/cloud-neoforge/src/main/resources/META-INF/neoforge.mods.toml index 82a733f7..cb280aca 100644 --- a/cloud-neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/cloud-neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -27,5 +27,11 @@ versionRange = "[1.20.5,)" ordering = "NONE" side = "BOTH" +[[dependencies.cloud]] +modId = "adventure_platform_neoforge" +type = "optional" +ordering = "AFTER" +side = "BOTH" + [[mixins]] config = "cloud.mixins.json"