diff --git a/build.gradle.kts b/build.gradle.kts index 531cc9eb..d929f396 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,17 @@ import net.fabricmc.loom.task.AbstractRunTask +import org.gradlex.javaecosystem.capabilities.rules.GuavaListenableFutureRule plugins { - val indraVer = "3.0.1" + val indraVer = "3.1.3" id("net.kyori.indra") version indraVer id("net.kyori.indra.publishing") version indraVer id("net.kyori.indra.publishing.sonatype") version indraVer id("net.kyori.indra.license-header") version indraVer - id("dev.architectury.loom") version "1.2-SNAPSHOT" + id("dev.architectury.loom") version "1.4-SNAPSHOT" +} + +repositories { + maven("https://maven.neoforged.net/releases/") } indra { @@ -17,17 +22,32 @@ license { header(file("HEADER")) } -val transitiveInclude: Configuration by configurations.creating +val transitiveInclude: Configuration by configurations.creating { + exclude("org.checkerframework") + exclude("org.apiguardian") +} loom.silentMojangMappingsLicense() dependencies { - minecraft("com.mojang:minecraft:1.20") + components.withModule(GuavaListenableFutureRule.MODULES[0]) { + // Ad-hoc rule to revert the effect of 'GuavaListenableFutureRule' (NeoForge has broken dependencies) + allVariants { + withCapabilities { + removeCapability(GuavaListenableFutureRule.CAPABILITY_GROUP, GuavaListenableFutureRule.CAPABILITY_NAME) + } + } + } + + minecraft("com.mojang:minecraft:1.20.2") mappings(loom.officialMojangMappings()) - forge("net.minecraftforge", "forge", "1.20-46.0.1") - api(transitiveInclude(forgeExtra(platform("cloud.commandframework:cloud-bom:1.8.4"))!!)!!) - api(transitiveInclude(forgeExtra("cloud.commandframework:cloud-core")!!)!!) - api(transitiveInclude(forgeExtra("cloud.commandframework:cloud-brigadier")!!)!!) + neoForge("net.neoforged", "neoforge", "20.2.54-beta") + + listOf("api", transitiveInclude.name, "forgeExtra").forEach { c -> + c(platform("cloud.commandframework:cloud-bom:1.8.4")) + c("cloud.commandframework:cloud-core") + c("cloud.commandframework:cloud-brigadier") + } } java { diff --git a/gradle.properties b/gradle.properties index f4af33d2..01c39625 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=cloud.commandframework -version=1.0.0+1.20-SNAPSHOT +version=1.0.0+1.20.2-SNAPSHOT -loom.platform=forge +loom.platform=neoforge org.gradle.jvmargs=-Xmx2G diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79..7f93135c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/settings.gradle.kts b/settings.gradle.kts index 5e77ff0e..d4f4a07c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,9 +2,9 @@ pluginManagement { repositories { gradlePluginPortal() maven("https://maven.fabricmc.net/") - maven("https://maven.minecraftforge.net") + maven("https://maven.neoforged.net/releases/") maven("https://maven.architectury.dev/") } } -rootProject.name = "cloud-forge" +rootProject.name = "cloud-neoforge" diff --git a/src/main/java/cloud/commandframework/forge/CloudForgeEntrypoint.java b/src/main/java/cloud/commandframework/forge/CloudForgeEntrypoint.java index 3651f15d..ad8eab82 100644 --- a/src/main/java/cloud/commandframework/forge/CloudForgeEntrypoint.java +++ b/src/main/java/cloud/commandframework/forge/CloudForgeEntrypoint.java @@ -40,14 +40,14 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.server.ServerStartingEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.server.permission.events.PermissionGatherEvent; -import net.minecraftforge.server.permission.nodes.PermissionDynamicContext; -import net.minecraftforge.server.permission.nodes.PermissionNode; -import net.minecraftforge.server.permission.nodes.PermissionTypes; +import net.neoforged.bus.api.EventPriority; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.server.ServerStartingEvent; +import net.neoforged.neoforge.server.permission.events.PermissionGatherEvent; +import net.neoforged.neoforge.server.permission.nodes.PermissionDynamicContext; +import net.neoforged.neoforge.server.permission.nodes.PermissionNode; +import net.neoforged.neoforge.server.permission.nodes.PermissionTypes; import org.checkerframework.checker.nullness.qual.Nullable; @Mod("cloud") @@ -55,8 +55,8 @@ public final class CloudForgeEntrypoint { private static boolean serverStartingCalled; public CloudForgeEntrypoint() { - MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGHEST, (ServerStartingEvent event) -> serverStartingCalled = true); - MinecraftForge.EVENT_BUS.addListener(EventPriority.LOW, CloudForgeEntrypoint::registerPermissions); + NeoForge.EVENT_BUS.addListener(EventPriority.HIGHEST, (ServerStartingEvent event) -> serverStartingCalled = true); + NeoForge.EVENT_BUS.addListener(EventPriority.LOW, CloudForgeEntrypoint::registerPermissions); if (Boolean.getBoolean("cloud.test_commands")) { testServerManager(); diff --git a/src/main/java/cloud/commandframework/forge/ForgeClientCommandManager.java b/src/main/java/cloud/commandframework/forge/ForgeClientCommandManager.java index 19c9fa02..2ba5fc99 100644 --- a/src/main/java/cloud/commandframework/forge/ForgeClientCommandManager.java +++ b/src/main/java/cloud/commandframework/forge/ForgeClientCommandManager.java @@ -34,14 +34,14 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.ClientCommandSourceStack; +import net.neoforged.neoforge.client.ClientCommandSourceStack; import org.checkerframework.checker.nullness.qual.NonNull; /** * A command manager for registering client-side commands. * *

All commands should be registered within mod initializers. Any registrations occurring after the first call to - * {@link net.minecraftforge.client.event.RegisterClientCommandsEvent} will be considered unsafe, and will only be permitted when the unsafe + * {@link net.neoforged.neoforge.client.event.RegisterClientCommandsEvent} will be considered unsafe, and will only be permitted when the unsafe * registration manager option is enabled.

* * @param the command sender type diff --git a/src/main/java/cloud/commandframework/forge/ForgeCommandRegistrationHandler.java b/src/main/java/cloud/commandframework/forge/ForgeCommandRegistrationHandler.java index 921e76c6..4ce6d6fc 100644 --- a/src/main/java/cloud/commandframework/forge/ForgeCommandRegistrationHandler.java +++ b/src/main/java/cloud/commandframework/forge/ForgeCommandRegistrationHandler.java @@ -38,11 +38,11 @@ import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.client.event.ClientPlayerNetworkEvent; -import net.minecraftforge.client.event.RegisterClientCommandsEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegisterCommandsEvent; +import net.neoforged.neoforge.client.ClientCommandHandler; +import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent; +import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.RegisterCommandsEvent; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.NonNull; @@ -132,8 +132,8 @@ static class Client extends ForgeCommandRegistrationHandler { @Override void initialize(final ForgeCommandManager manager) { super.initialize(manager); - MinecraftForge.EVENT_BUS.addListener(this::registerCommands); - MinecraftForge.EVENT_BUS.addListener((ClientPlayerNetworkEvent.LoggingOut event) -> this.registerEventFired = false); + NeoForge.EVENT_BUS.addListener(this::registerCommands); + NeoForge.EVENT_BUS.addListener((ClientPlayerNetworkEvent.LoggingOut event) -> this.registerEventFired = false); } @Override @@ -181,7 +181,7 @@ static class Server extends ForgeCommandRegistrationHandler { @Override void initialize(final ForgeCommandManager manager) { super.initialize(manager); - MinecraftForge.EVENT_BUS.addListener(this::registerAllCommands); + NeoForge.EVENT_BUS.addListener(this::registerAllCommands); } @Override diff --git a/src/main/java/cloud/commandframework/forge/ForgeServerCommandManager.java b/src/main/java/cloud/commandframework/forge/ForgeServerCommandManager.java index 8add8519..eae39aaa 100644 --- a/src/main/java/cloud/commandframework/forge/ForgeServerCommandManager.java +++ b/src/main/java/cloud/commandframework/forge/ForgeServerCommandManager.java @@ -36,9 +36,9 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.server.permission.PermissionAPI; -import net.minecraftforge.server.permission.nodes.PermissionNode; -import net.minecraftforge.server.permission.nodes.PermissionTypes; +import net.neoforged.neoforge.server.permission.PermissionAPI; +import net.neoforged.neoforge.server.permission.nodes.PermissionNode; +import net.neoforged.neoforge.server.permission.nodes.PermissionTypes; public final class ForgeServerCommandManager extends ForgeCommandManager { @@ -81,7 +81,7 @@ public ForgeServerCommandManager( ); if (CloudForgeEntrypoint.hasServerAlreadyStarted()) { - throw new IllegalStateException("ForgefabrServerCommandManager was created too late! Because command registration " + throw new IllegalStateException("ForgeServerCommandManager was created too late! Because command registration " + "occurs before the server instance is created, commands should be registered in mod initializers."); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 6fa9fc69..bd720dad 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,2 +1,2 @@ -public net.minecraft.commands.Commands$CommandSelection f_82144_ -public net.minecraft.commands.Commands$CommandSelection f_82145_ +public net.minecraft.commands.Commands$CommandSelection includeIntegrated +public net.minecraft.commands.Commands$CommandSelection includeDedicated diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 2ffa5e32..b7020860 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "[46,)" +loaderVersion = "[1,)" license = "MIT" issueTrackerURL = "https://github.com/Incendo/cloud-forge/issues" showAsResourcePack = false @@ -14,15 +14,15 @@ description = "Cloud Command Framework on Forge" displayTest = "IGNORE_ALL_VERSION" [[dependencies.cloud]] -modId = "forge" +modId = "neoforge" mandatory = true -versionRange = "[46,)" +versionRange = "[20.2,)" ordering = "NONE" side = "BOTH" [[dependencies.cloud]] modId = "minecraft" mandatory = true -versionRange = "[1.20,1.21)" +versionRange = "[1.20.2,1.21)" ordering = "NONE" side = "BOTH"