diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..b9f4da548 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: "Release" + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Clone project + uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: "microsoft" + java-version: 21 + - name: Fix borked permissions + run: chmod +x ./gradlew + - name: Run gradle tasks + uses: gradle/gradle-build-action@v2 + env: + MR_TOKEN: ${{ secrets.MR_TOKEN }} + CF_TOKEN: ${{ secrets.CF_TOKEN }} + MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + arguments: clean build publish publishMods diff --git a/.gitignore b/.gitignore index 5cd074a6a..b2b67e101 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ .settings/org.eclipse.buildship.core.prefs *.launch .settings/org.eclipse.jdt.core.prefs -*.prefs \ No newline at end of file +*.prefs +.DS_Store diff --git a/update/changelog.md b/CHANGELOG.md similarity index 99% rename from update/changelog.md rename to CHANGELOG.md index d2d4caa03..4e12e9422 100644 --- a/update/changelog.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 1.3.6+mc1.21.1 +# 1.3.7+mc1.21.1 * Added recipes for AA crops in the IE cloche. # 1.3.6+mc1.21.1 diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 7ae0e3cdf..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,35 +0,0 @@ -pipeline { - agent any - stages { - stage('Clean') { - steps { - sh './gradlew clean --no-daemon' - } - } - - stage('Build') { - steps { - sh './gradlew build --no-daemon' - } - } - - stage('Upload Artifacts') { - steps { - archiveArtifacts 'build/libs/**.jar' - } - } - - stage('Publish') { - when { - branch '1.12.2' - } - steps { - sh './gradlew publish --no-daemon' - } - } - - } - environment { - local_maven = '/var/www/maven' - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 75f254de4..3b730b94e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,76 +1,92 @@ plugins { id 'java-library' - id 'eclipse' - id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.165' + id 'net.neoforged.moddev' version '1.0.21' + id "me.modmuss50.mod-publish-plugin" version "0.7.4" } -def buildSuffix = System.getenv('BUILD_NUMBER') ? "-b${System.getenv('BUILD_NUMBER')}" : "" +tasks.named('wrapper', Wrapper).configure { + distributionType = Wrapper.DistributionType.BIN +} + +version = "$mod_version+mc${game_version}" +group = "de.ellpeck" -version = "$mod_version+mc${game_version}${buildSuffix}" -group = "de.ellpeck.actuallyadditions" base { - archivesName = "ActuallyAdditions" + archivesName = "actuallyadditions" } java.toolchain.languageVersion = JavaLanguageVersion.of(21) -if (rootProject.file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { - minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') -} +neoForge { + version = project.neo_version -runs { - // applies to all the run configs below - configureEach { net.neoforged.gradle.dsl.common.runs.run.Run run -> - //Limit ram usage for the dev environment to 4GB - jvmArgument '-Xmx4G' + parchment { + mappingsVersion = project.parchment_mappings_version + minecraftVersion = project.hasProperty("parchment_minecraft_version") ? project.parchment_minecraft_version : project.game_version + } - if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) { - run.jvmArgument("-XX:+AllowEnhancedClassRedefinition") + runs { + client { + client() + systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" + programArguments.addAll '--width=1920', '--height=1080' } - modSource project.sourceSets.main + client2 { + client() + + programArguments.addAll '--username', 'Dev2' + + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" + } + + server { + server() + programArgument '--nogui' + systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" + } + + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" + } + + data { + data() + programArguments.addAll '--mod', "actuallyadditions", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } + + configureEach { run -> + systemProperty 'forge.logging.markers', 'REGISTRIES' + logLevel = org.slf4j.event.Level.DEBUG + + jvmArgument '-Xmx4G' + + if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) { + run.jvmArgument("-XX:+AllowEnhancedClassRedefinition") + } + } } - client { - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" - } - client2 { - configure ("client") - - programArguments.addAll '--username', 'Dev2' - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" - } - - server { - systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions" - programArgument '--nogui' - } - - data { - // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it - // workingDirectory project.file('run-data') - - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - programArguments.addAll '--mod', "actuallyadditions", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + mods { + "actuallyadditions" { + sourceSet(sourceSets.main) + } } } sourceSets.main.resources { srcDir 'src/generated/resources' } -// Sets up a dependency configuration called 'localRuntime'. -// This configuration should be used instead of 'runtimeOnly' to declare -// a dependency that will be present for runtime testing but that is -// "optional", meaning it will not be pulled by dependents of this mod. configurations { runtimeClasspath.extendsFrom localRuntime } repositories { + maven { + url = "https://maven.neoforged.net/releases" + } maven { url = "https://maven.blamejared.com" } @@ -84,8 +100,6 @@ repositories { } dependencies { - implementation "net.neoforged:neoforge:${neo_version}" - compileOnly "mezz.jei:jei-${jei_minecraft}-common-api:${jei_version}" compileOnly "mezz.jei:jei-${jei_minecraft}-neoforge-api:${jei_version}" @@ -126,7 +140,28 @@ jar { from sourceSets.main.output } -task apiJar(type: Jar) { +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { + var replaceProperties = [ + minecraft_version : game_version, + minecraft_version_range: game_version_range, + neo_version : neo_version, + neo_version_range : neo_version_range, + loader_version_range : loader_version_range, + mod_id : "actuallyadditions", + mod_name : "Actually Additions", + mod_version : mod_version, + ] + + inputs.properties replaceProperties + expand replaceProperties + from "src/main/templates" + into "build/generated/sources/modMetadata" +} + +sourceSets.main.resources.srcDir generateModMetadata +neoForge.ideSyncTask generateModMetadata + +tasks.register('apiJar', Jar) { from sourceSets.main.output from sourceSets.main.java archiveClassifier.set('api') @@ -137,12 +172,13 @@ javadoc { include 'de/ellpeck/actuallyadditions/api/**' } -task javadocJar(type: Jar, dependsOn: javadoc) { +tasks.register('javadocJar', Jar) { + dependsOn javadoc from 'build/docs/javadoc' archiveClassifier.set('javadoc') } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar', Jar) { from sourceSets.main.java archiveClassifier.set('sources') } @@ -151,38 +187,111 @@ artifacts { archives sourcesJar, apiJar, javadocJar } -publishing { - tasks.publish.dependsOn build - publications { - mavenJava(MavenPublication) { - groupId = group - artifactId = base.archivesName.get() - version = version +publishing { + publications { + register('mavenJava', MavenPublication) { from components.java + // Add sources and javadoc to the publication artifact sourcesJar artifact apiJar artifact javadocJar - - pom.withXml { - def node = asNode() - if (node.dependencies.size() > 0) - node.remove(node.dependencies) - } } } + repositories { - maven { - url "file://" + System.getenv("local_maven") + def token = providers.environmentVariable("MAVEN_TOKEN") + if (token.isPresent()) { + maven { + url "https://maven.saps.dev/releases" + credentials { + username = "ell" + password = token.get() + } + } } } } -// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' +} + idea { module { downloadSources = true downloadJavadoc = true } } + +/** + * Seek out the changelog for the current version and return it as a string. + */ +def createChangelog = () -> { + def changelogText = new File("CHANGELOG.md").text + def changelog = "" + + def lines = changelogText.split("\n") + def inChangelog = false + for (int i = 0; i < lines.size(); i++) { + def line = lines[i] + if (line.startsWith("# ")) { + if (inChangelog) { + break + } else { + if (line.contains(mod_version)) { + inChangelog = true + } + } + } + + if (inChangelog) { + changelog += line + "\n" + } + } + + def output = changelog.trim() + return output.empty ? "No changelog found" : output +} + +def cfToken = providers.environmentVariable("CF_TOKEN") +def mrToken = providers.environmentVariable("MR_TOKEN") +def ghToken = providers.environmentVariable("GITHUB_TOKEN") + +publishMods { + dryRun = !cfToken.isPresent() || !mrToken.isPresent() || !ghToken.isPresent() + changelog = createChangelog().trim() + version = mod_version + displayName = "Actually Additions ${mod_version}" + type = STABLE + + file = jar.archiveFile + + additionalFiles.from apiJar.archiveFile + additionalFiles.from javadocJar.archiveFile + additionalFiles.from sourcesJar.archiveFile + + modLoaders.add("neoforge") + + curseforge { + accessToken = cfToken + projectId = "228404" + minecraftVersions.add(game_version) + javaVersions.add(JavaVersion.VERSION_21) + } + + modrinth { + accessToken = mrToken + projectId = "4K7Q3nqd" + minecraftVersions.add(game_version) + } + + github { + repository = "Ellpeck/ActuallyAdditions" + accessToken = ghToken + commitish = providers.environmentVariable("GITHUB_SHA").orElse("dryRun") + tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryRun") + } +} diff --git a/gradle.properties b/gradle.properties index 72c446dd9..6073706ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,23 @@ org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false -# Actually Additions +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configuration-cache=false mod_version=1.3.7 # Forge game_version=1.21.1 +game_version_range=[1.21.1,1.22) + neo_version=21.1.71 +neo_version_range=[21.1,21.2) +loader_version_range=4 # Parchment (Mappings) -neogradle.subsystems.parchment.minecraftVersion=1.21 -neogradle.subsystems.parchment.mappingsVersion=2024.07.28 -neogradle.subsystems.conventions.runs.create-default-run-per-type=false +# Uncomment to apply a different mc version for parchment +parchment_minecraft_version=1.21 +parchment_mappings_version=2024.07.28 # Other mods jei_minecraft=1.21.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138c..09523c0e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/libs/FastWorkbench-1.12.2-1.3.2.jar b/libs/FastWorkbench-1.12.2-1.3.2.jar deleted file mode 100644 index 5f43fdda6..000000000 Binary files a/libs/FastWorkbench-1.12.2-1.3.2.jar and /dev/null differ diff --git a/settings.gradle b/settings.gradle index c37689192..de72f59b3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,4 +11,5 @@ pluginManagement { plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } + rootProject.name = "actuallyadditions" diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java deleted file mode 100644 index df830fb91..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ThreadUpdateChecker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.update; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.CommonConfig; -import de.ellpeck.actuallyadditions.mod.util.Util; - -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Properties; - -public class ThreadUpdateChecker extends Thread { - - public ThreadUpdateChecker() { - this.setName(ActuallyAdditions.NAME + " Update Checker"); - this.setDaemon(true); - this.start(); - } - - @Override - public void run() { - ActuallyAdditions.LOGGER.info("Starting Update Check..."); - try { - URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/main/update/updateVersions.properties"); - Properties updateProperties = new Properties(); - updateProperties.load(new InputStreamReader(newestURL.openStream())); - - String currentMcVersion = Util.getMcVersion(); - if (CommonConfig.Other.UPDATE_CHECK_VERSION_SPECIFIC.get()) { - String newestVersionProp = updateProperties.getProperty(currentMcVersion); - - UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp); - UpdateChecker.updateVersionString = currentMcVersion + "-r" + newestVersionProp; - } else { - int highest = 0; - String highestString = ""; - - for (String updateMC : updateProperties.stringPropertyNames()) { - String updateVersion = updateProperties.getProperty(updateMC); - int update = Integer.parseInt(updateVersion); - if (highest < update) { - highest = update; - highestString = updateMC + "-r" + updateVersion; - } - } - - UpdateChecker.updateVersionInt = highest; - UpdateChecker.updateVersionString = highestString; - } - - String clientVersionString = Util.getMajorModVersion(); - int clientVersion = Integer.parseInt(clientVersionString.contains("_") ? clientVersionString.substring(0, clientVersionString.indexOf("_")) : clientVersionString); - if (UpdateChecker.updateVersionInt > clientVersion) { - UpdateChecker.needsUpdateNotify = true; - } - - ActuallyAdditions.LOGGER.info("Update Check done!"); - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Update Check failed!", e); - UpdateChecker.checkFailed = true; - } - - if (!UpdateChecker.checkFailed) { - if (UpdateChecker.needsUpdateNotify) { - ActuallyAdditions.LOGGER.info("There is an Update for " + ActuallyAdditions.NAME + " available!"); - ActuallyAdditions.LOGGER.info("Current Version: " + ActuallyAdditions.VERSION + ", newest Version: " + UpdateChecker.updateVersionString + "!"); - ActuallyAdditions.LOGGER.info("View the Changelog at " + UpdateChecker.CHANGELOG_LINK); - ActuallyAdditions.LOGGER.info("Download at " + UpdateChecker.DOWNLOAD_LINK); - } else { - ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME + " is up to date!"); - } - } - - UpdateChecker.threadFinished = true; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java deleted file mode 100644 index df8c1e42a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file ("UpdateChecker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.update; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.client.Minecraft; -import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.player.Player; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.neoforge.client.event.ClientTickEvent; -import net.neoforged.neoforge.common.NeoForge; - -public class UpdateChecker { - - public static final String DOWNLOAD_LINK = "http://ellpeck.de/actadddownload"; - public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog"; - public static boolean checkFailed; - public static boolean needsUpdateNotify; - public static int updateVersionInt; - public static String updateVersionString; - public static boolean threadFinished = false; - - public UpdateChecker() { -// if (CommonConfig.OTHER.DO_UPDATE_CHECK.get() && !Util.isDevVersion()) { -// ActuallyAdditions.LOGGER.info("Initializing Update Checker..."); -// new ThreadUpdateChecker(); -// MinecraftForge.EVENT_BUS.register(this); -// } - } - - - @SubscribeEvent(receiveCanceled = true) - public void onTick(ClientTickEvent.Pre event) { - if (Minecraft.getInstance().player != null) { - Player player = Minecraft.getInstance().player; - if (UpdateChecker.checkFailed) { - player.displayClientMessage(Component.translatable("info.actuallyadditions.update.failed"), false); - } else if (UpdateChecker.needsUpdateNotify) { - player.displayClientMessage(Component.translatable("info.actuallyadditions.update.generic"), false); - player.displayClientMessage(Component.translatable("info.actuallyadditions.update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString), false); - player.displayClientMessage(Component.translatable("info.actuallyadditions.update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK), false); - } - if (threadFinished) { - NeoForge.EVENT_BUS.unregister(this); - } - } - } -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 66112eb33..d25ef625f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -8,4 +8,4 @@ public net.minecraft.world.inventory.InventoryMenu TEXTURE_EMPTY_SLOTS public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates public net.minecraft.world.entity.npc.VillagerTrades$ItemsForEmeralds -public net.minecraft.world.entity.npc.VillagerTrades$EmeraldForItems \ No newline at end of file +public net.minecraft.world.entity.npc.VillagerTrades$EmeraldForItems diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml similarity index 56% rename from src/main/resources/META-INF/neoforge.mods.toml rename to src/main/templates/META-INF/neoforge.mods.toml index 961f45804..b0a12609c 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -1,30 +1,33 @@ - modLoader="javafml" -loaderVersion="[4,)" +loaderVersion="${loader_version_range}" license="MIT" +issueTrackerURL="https://github.com/Ellpeck/ActuallyAdditions/issues" + [[mods]] modId="actuallyadditions" -version="${file.jarVersion}" -displayName="Actually Additions" -#logoFile="logo.png" +version="${mod_version}" +displayName="${mod_name}" +displayURL="https://github.com/Ellpeck/ActuallyAdditions" credits="Author: Ellpeck; Textures and Models: BootyToast, GlenthorLP, canitzp; Porters: Flanks, MrBysco, ErrorMikey; 1.20+ Textures: Ridanisaurus" authors="Ellpeck" description=''' Do you want Automation? Wireless Transport? Better Machines? A cup o\' Coffee? Chests? Better Hoppers? Leaf Blowers? Faster Growth? Plants? Well, Actually Additions has all that and a lot more! ''' + [[mixins]] config = "actuallyadditions.mixins.json" [[dependencies.actuallyadditions]] - modId="neoforge" - type="required" - versionRange="[21.1.1,)" - ordering="NONE" - side="BOTH" +modId="neoforge" +type="required" +versionRange="${neo_version_range}" +ordering="NONE" +side="BOTH" +# Here's another dependency [[dependencies.actuallyadditions]] - modId="minecraft" - type="required" - versionRange="[1.21.1,1.22)" - ordering="NONE" - side="BOTH" +modId="minecraft" +type="required" +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" diff --git a/update/updateVersions.properties b/update/updateVersions.properties deleted file mode 100644 index bff0f8155..000000000 --- a/update/updateVersions.properties +++ /dev/null @@ -1,11 +0,0 @@ -1.7.10=21 -1.8.9=26 -1.9=33 -1.9.4=45 -1.10=46 -1.10.2=105 -1.11=92 -1.11.2=110 -1.12=118 -1.12.1=121 -1.12.2=151 \ No newline at end of file