diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21b9119..ad15e75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,33 +1,16 @@ name: Build mod jar on: - [workflow_dispatch, push] + workflow_dispatch: + push: + pull_request: permissions: - contents: read + contents: write jobs: build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6 - - name: Set up JDK - uses: actions/setup-java@v5 - with: - java-version: '25' - distribution: 'temurin' - - uses: gradle/actions/setup-gradle@v6 - with: - gradle-version: 9.5.1 - name: Set up Gradle - - name: Add permission - run: chmod +x ./gradlew - - name: Execute Gradle build - run: ./gradlew build - - - name: Upload a Build Artifact - uses: actions/upload-artifact@v7 - with: - path: build/libs + uses: FormlessDragon/.github/.github/workflows/build.yml@main + secrets: inherit + permissions: + contents: write diff --git a/.github/workflows/release-to-cf-mr.yml b/.github/workflows/release-to-cf-mr.yml deleted file mode 100644 index 95fe5bb..0000000 --- a/.github/workflows/release-to-cf-mr.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Releases to CurseForge and/or Modrinth - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Set up JDK - uses: actions/setup-java@v5 - with: - java-version: '25' - distribution: 'temurin' - - - uses: gradle/actions/setup-gradle@v6 - with: - gradle-version: 9.5.1 - name: Set up Gradle - - - name: Add permission - run: chmod +x ./gradlew - - - name: Execute Gradle build - run: ./gradlew build - - - name: Get Changes between Tags - id: changes - uses: simbo/changes-between-tags-action@v1 - - - uses: Kir-Antipov/mc-publish@v3.3.0 - with: - # Only include this section if you wish to publish - # your assets on Modrinth. - modrinth-id: placeholder - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - - # Only include this section if you wish to publish - # your assets on CurseForge. - curseforge-id: placeholder - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - - files: | - build/libs/!(*-@(dev|sources|javadoc)).jar - build/libs/*-@(dev|sources|javadoc).jar - loaders: forge - game-versions: 1.12.2 - java: | - 25 - version: ${{ steps.changes.outputs.tag }} - changelog: ${{ steps.changes.outputs.changes }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c88009..e6428e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,32 +1,17 @@ -name: Releases +name: Release tagged build on: push: - tags: - - "*" + tags: ['*'] + +permissions: + contents: write + actions: write jobs: - build: - runs-on: ubuntu-latest + release: + uses: FormlessDragon/.github/.github/workflows/release.yml@main + secrets: inherit permissions: contents: write - steps: - - uses: actions/checkout@v6 - - name: Set up JDK - uses: actions/setup-java@v5 - with: - java-version: '25' - distribution: 'temurin' - - uses: gradle/actions/setup-gradle@v6 - with: - gradle-version: 9.5.1 - name: Set up Gradle - - name: Add permission - run: chmod +x ./gradlew - - name: Execute Gradle build - run: ./gradlew build - - - uses: ncipollo/release-action@v1.21.0 - with: - artifacts: "build/libs/*" - generateReleaseNotes: true + actions: write diff --git a/.github/workflows/runtime-test.yml b/.github/workflows/runtime-test.yml new file mode 100644 index 0000000..b20d5d7 --- /dev/null +++ b/.github/workflows/runtime-test.yml @@ -0,0 +1,18 @@ +name: Runtime Test + +on: + workflow_dispatch: + workflow_call: + pull_request: + push: + branches: [master] + merge_group: + +permissions: + contents: read + actions: write + +jobs: + runtime-test: + uses: FormlessDragon/.github/.github/workflows/runtime-test.yml@main + secrets: inherit diff --git a/build.gradle b/build.gradle index 7f31cbb..8740e73 100644 --- a/build.gradle +++ b/build.gradle @@ -1,35 +1,74 @@ +import org.jetbrains.gradle.ext.Gradle + plugins { id 'java' id 'java-library' id 'maven-publish' - id 'com.gradleup.shadow' version '9.4.1' id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1' - id 'xyz.wagyourtail.unimined' version '1.4.18-kappa' - id 'net.kyori.blossom' version '2.2.0' + id 'com.gradleup.shadow' version '9.4.0' + id 'xyz.wagyourtail.unimined' version '1.4.37-kappa' + id 'com.diffplug.spotless' version '8.4.0' } -import org.jetbrains.gradle.ext.Gradle +apply from: 'gradle/scripts/helpers.gradle' + +private String gitOutput(List args, String fallback) { + try { + def process = new ProcessBuilder(['git'] + args) + .directory(rootProject.projectDir) + .redirectErrorStream(true) + .start() + def stdout = process.inputStream.getText('UTF-8').trim() + if (process.waitFor() == 0 && !stdout.isEmpty()) { + return stdout + } + } catch (Exception ignored) { + // Fall through to the fallback for source archives or environments without git. + } + return fallback +} -ext { - //noinspection GroovyAssignabilityCheck - access_transformer_locations = "${mod_id}_at.cfg" +private String defaultModVersion() { + def previousTag = gitOutput(['describe', '--tags', '--abbrev=0', '--exclude=dev'], '0.0.0') + def shortHash = gitOutput(['rev-parse', '--short', 'HEAD'], 'unknown') + return "${previousTag}+${shortHash}" } -version = mod_version -group = root_package +if (!gradle.startParameter.projectProperties.containsKey('mod_version')) { + project.setProperty('mod_version', defaultModVersion()) +} + +// Early Assertions +assertProperty 'mod_version' +assertProperty 'root_package' +assertProperty 'mod_id' +assertProperty 'mod_name' + +assertSubProperties 'use_lombok_ap', 'lombok_version' +assertSubProperties 'use_access_transformer', 'access_transformer_locations' +assertSubProperties 'is_coremod', 'coremod_includes_mod', 'coremod_plugin_class_name' +assertSubProperties 'use_asset_mover', 'asset_mover_version' + +setDefaultProperty 'generate_sources_jar', true, false +setDefaultProperty 'generate_javadocs_jar', true, false +setDefaultProperty 'minecraft_username', true, 'Developer' +setDefaultProperty 'extra_jvm_args', false, '' + +version = propertyString('mod_version') +group = propertyString('root_package') base { - archivesName = mod_id + archivesName = propertyString('mod_id') } java { toolchain { languageVersion = JavaLanguageVersion.of(25) } - if (generate_sources_jar.toBoolean()) { + if (propertyBool('generate_sources_jar')) { withSourcesJar() } - if (generate_javadocs_jar.toBoolean()) { + if (propertyBool('generate_javadocs_jar')) { withJavadocJar() } } @@ -43,9 +82,8 @@ configurations { runtimeOnly.extendsFrom(modRuntimeOnly) } -def remapTaskName = enable_shadow.toBoolean() ? "remapShadowJar" : "remapJar" +String remapTaskName = propertyBool('enable_shadow') ? "remapShadowJar" : "remapJar" -//noinspection GroovyAssignabilityCheck unimined.minecraft { version "1.12.2" @@ -54,22 +92,23 @@ unimined.minecraft { } cleanroom { - if (use_access_transformer.toBoolean()) { - accessTransformer "${rootProject.projectDir}/src/main/resources/$access_transformer_locations" + if (propertyBool('use_access_transformer')) { + accessTransformer "${rootProject.projectDir}/src/main/resources/${propertyString('access_transformer_locations')}" } - loader "0.5.12-alpha" + loader "0.5.14-alpha" + runs.auth.username = minecraft_username runs.all { - args += ['--username', minecraft_username] - def extraArgs = extra_jvm_args + systemProperty("crl.dev.mixin", "mixins/${mod_id}.mixins.json") + def extraArgs = propertyString('extra_jvm_args') if (extraArgs != null && !extraArgs.trim().isEmpty()) { jvmArgs += extraArgs.split { "\\s+" }.toList() } - if (enable_foundation_debug.toBoolean()) { + if (propertyBool('enable_foundation_debug')) { systemProperty("foundation.dump", "true") systemProperty("foundation.verbose", "true") } - if (is_coremod.toBoolean()) { - systemProperty("fml.coreMods.load", coremod_plugin_class_name) + if (propertyBool('is_coremod')) { + systemProperty("fml.coreMods.load", propertyString('coremod_plugin_class_name')) } return } @@ -77,13 +116,12 @@ unimined.minecraft { defaultRemapJar = false - String jarTaskName = enable_shadow.toBoolean() ? "shadowJar" : "jar" + String jarTaskName = propertyBool('enable_shadow') ? "shadowJar" : "jar" remap(tasks.named(jarTaskName).get()) { mixinRemap { enableBaseMixin() enableMixinExtra() - disableRefmap() } } @@ -94,82 +132,101 @@ unimined.minecraft { } dependencies { - if (use_asset_mover.toBoolean()) { - implementation "com.cleanroommc:assetmover:${asset_mover_version}" + if (propertyBool('use_lombok_ap')) { + compileOnly "org.projectlombok:lombok:${propertyString('lombok_version')}" + annotationProcessor "org.projectlombok:lombok:${propertyString('lombok_version')}" + + testCompileOnly "org.projectlombok:lombok:${propertyString('lombok_version')}" + testAnnotationProcessor "org.projectlombok:lombok:${propertyString('lombok_version')}" } - if (enable_junit_testing.toBoolean()) { + if (propertyBool('use_asset_mover')) { + implementation "com.cleanroommc:assetmover:${propertyString('asset_mover_version')}" + } + if (propertyBool('enable_junit_testing')) { testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } + compileOnly 'com.google.code.findbugs:jsr305:3.0.2' } apply from: 'gradle/scripts/dependencies.gradle' +def generatedTagsSourceDir = layout.buildDirectory.dir('generated/sources/tags/java') +def generateTagsSource = tasks.register('generateTagsSource') { + def tagsPackage = "${propertyString('root_package')}.${propertyString('mod_id')}" + def outputFile = generatedTagsSourceDir.map { + it.file("${tagsPackage.replace('.', '/')}/Tags.java") + } + + inputs.property('root_package', propertyString('root_package')) + inputs.property('mod_id', propertyString('mod_id')) + inputs.property('mod_name', propertyString('mod_name')) + inputs.property('mod_version', propertyString('mod_version')) + outputs.file(outputFile) + + doLast { + def file = outputFile.get().asFile + file.parentFile.mkdirs() + file.text = """package ${tagsPackage}; + +public final class Tags { + + public static final String MOD_ID = "${propertyString('mod_id')}"; + public static final String MOD_NAME = "${propertyString('mod_name')}"; + public static final String VERSION = "${propertyString('mod_version')}"; + + private Tags() { + } +} +""" + } +} + processResources { rename '(.+_at.cfg)', 'META-INF/$1' + def resourceProps = [ + mod_id : propertyString('mod_id'), + mod_name : propertyString('mod_name'), + mod_version : propertyString('mod_version'), + mod_description : propertyString('mod_description'), + mod_authors : propertyStringList('mod_authors', ',').collect { it.strip() }.join('", "'), + mod_credits : propertyString('mod_credits'), + mod_license : propertyString('mod_license'), + mod_url : propertyString('mod_url'), + mod_issue_tracker_url: propertyString('mod_issue_tracker_url'), + mod_update_json : propertyString('mod_update_json'), + mod_icon_item : propertyString('mod_icon_item'), + mod_logo_path : propertyString('mod_logo_path'), + mod_icon_path : propertyString('mod_icon_path'), + mod_background_path : propertyString('mod_background_path') + ] + inputs.properties(resourceProps) + filesMatching(['mcmod.info', 'pack.mcmeta']) { + expand(resourceProps) + } } sourceSets { main { - blossom { - javaSources { - property('mod_id', mod_id) - property('mod_name', mod_name) - property('mod_version', mod_version) - property('package', "${root_package}.${mod_id}") - } - resources { - property('mod_id', mod_id) - property('mod_name', mod_name) - property('mod_version', mod_version) - property('mod_description', mod_description) - property('mod_authors', mod_authors.toString().split(',').findAll { !it.isBlank() }.collect { "\"${it.strip()}\"" }.join(', ')) - property('mod_credits', mod_credits) - property('mod_url', mod_url) - property('mod_update_json', mod_update_json) - property('mod_logo_path', mod_logo_path) - } - } - } -} - -idea { - module { - inheritOutputDirs = true - } - project { - settings { - runConfigurations { - '1. Build'(Gradle) { - taskNames = ["build"] - } - '2. Run Client'(Gradle) { - taskNames = ["runClient"] - } - '3. Run Server'(Gradle) { - taskNames = ["runServer"] - } - } - compiler.javac { - afterEvaluate { - javacAdditionalOptions = '-encoding utf8' - moduleJavacAdditionalOptions = [ - (project.name + '.main'): tasks.compileJava.options.compilerArgs.collect { "\"${it}\"" }.join(' ') - ] - } - } + java { + srcDir generatedTagsSourceDir } } } -if (!enable_shadow.toBoolean()) { +if (!propertyBool('enable_shadow')) { shadowJar.enabled = false } compileJava { + dependsOn(generateTagsSource) sourceCompatibility = targetCompatibility = JavaVersion.VERSION_25 } +tasks.matching { it.name == 'sourcesJar' }.configureEach { + dependsOn(generateTagsSource) +} + jar { archiveClassifier = 'dev' duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -182,20 +239,20 @@ jar { manifest { def attribute_map = [:] attribute_map['ModType'] = "CRL" + attribute_map['MixinConfigs'] = "mixins/${mod_id}.mixins.json" if (configurations.contain.size() > 0) { attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') attribute_map['NonModDeps'] = true } - if (is_coremod.toBoolean()) { - attribute_map['FMLCorePlugin'] = coremod_plugin_class_name - if (coremod_includes_mod.toBoolean()) { + if (propertyBool('is_coremod')) { + attribute_map['FMLCorePlugin'] = propertyString('coremod_plugin_class_name') + if (propertyBool('coremod_includes_mod')) { attribute_map['FMLCorePluginContainsFMLMod'] = true } } - if (use_access_transformer.toBoolean()) { - attribute_map['FMLAT'] = access_transformer_locations + if (propertyBool('use_access_transformer')) { + attribute_map['FMLAT'] = propertyString('access_transformer_locations') } - attribute_map['MixinConfigs'] = 'mixins/ae2additions.mixins.json' attributes(attribute_map) } } @@ -204,7 +261,6 @@ jar { shadowJar { - //noinspection GroovyAssignabilityCheck,GroovyAccessibility configurations = [project.configurations.shadow] archiveClassifier = "shadow" } @@ -219,6 +275,38 @@ tasks.named(remapTaskName).configure { } } +idea { + module { + inheritOutputDirs = true + } + project { + settings { + runConfigurations { + "0. Apply Spotless"(Gradle) { + taskNames = ["spotlessApply"] + } + "1. Run Client"(Gradle) { + taskNames = ["runClient"] + } + "2. Run Server"(Gradle) { + taskNames = ["runServer"] + } + "3. Build Mod"(Gradle) { + taskNames = ["build"] + } + } + compiler.javac { + afterEvaluate { + javacAdditionalOptions = "-encoding utf8" + moduleJavacAdditionalOptions = [ + (project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ') + ] + } + } + } + } +} + compileTestJava { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_25 } @@ -228,7 +316,7 @@ test { javaLauncher.set(javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }) - if (show_testing_output.toBoolean()) { + if (propertyBool('show_testing_output')) { testLogging { showStandardStreams = true } @@ -240,4 +328,4 @@ tasks.withType(JavaCompile).configureEach { } apply from: 'gradle/scripts/publishing.gradle' -apply from: 'gradle/scripts/extra.gradle' +apply from: 'gradle/scripts/extra.gradle' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index b075c5c..352701b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,11 @@ # Gradle Properties org.gradle.jvmargs = -Xmx3G +# Source Options +# Use Lombok annotation processor +use_lombok_ap = false +lombok_version = 1.18.38 + # Compilation Options generate_sources_jar = true generate_javadocs_jar = false @@ -28,11 +33,24 @@ mod_name = Applied Additions mod_description = Applied Energistics 2 Supergiant additions mod_url = mod_update_json = -# Delimit authors with commas +# Delimit authors with commas. Eg: Author1,Author2 mod_authors = mod_credits = +# Path to a png file. Eg: assets/modid/logo.png mod_logo_path = +# Catalogue Extra Metadata (Optional) +mod_license = LGPL-3.0 +mod_issue_tracker_url = https://github.com/FormlessDragon/Applied-Additions/issues +# Path to a square png file +mod_icon_path = +# An item to be rendered as the mod icon in Catalogue mod list, +# Formatted as modid:item_name(:meta) +# Final icon will be mod_icon_path if path is not empty. +mod_icon_item = +# Path to a 512x256 png file +mod_background_path = + # Run Configurations # If multiple arguments/tweak classes are stated, use spaces as the delimiter minecraft_username = Developer @@ -41,11 +59,22 @@ enable_foundation_debug = false # Maven Publishing (Provide secret: MAVEN_USER, MAVEN_PASS) publish_to_maven = false +publish_to_jitpack = false # Good for debugging artifacts before uploading to remote maven # GitHub actions won't run if this is true, test this by running the task `publishToMavenLocal` publish_to_local_maven = false maven_name = ${mod_name} maven_url = +maven_group = ${root_package} +maven_artifact_id = ${mod_id} +maven_developer_id = +maven_developer_name = +maven_license_name = ${mod_license} +maven_license_url = +maven_scm_url = ${mod_url} +jitpack_group = +jitpack_artifact_id = +jitpack_version = # If any properties changes below this line, refresh gradle again to ensure everything is working correctly. # ---------------------------------------------------------------------------------------------------------------------- @@ -58,6 +87,7 @@ maven_url = # If multiple locations are stated, use spaces as the delimiter # WARNING: Use MCP name in AT file. Unimined will remap it to srg name when building. use_access_transformer = false +access_transformer_locations = ${mod_id}_at.cfg # Coremods # The most powerful way to change java classes at runtime, it is however very primitive with little documentation. diff --git a/gradle/scripts/extra.gradle b/gradle/scripts/extra.gradle index 106911e..53cec7b 100644 --- a/gradle/scripts/extra.gradle +++ b/gradle/scripts/extra.gradle @@ -1,5 +1,276 @@ // You may write any gradle buildscript component in this file // This file is automatically applied after build.gradle + dependencies.gradle is ran -// Helper methods (assertProperty, assertSubProperties, setDefaultProperty) are -// defined directly in build.gradle's script scope and exported via ext. +def minecraftVersion = '1.12.2' +def cleanroomVersion = '0.6.10-alpha' + +def cleanroomInstaller = configurations.maybeCreate('cleanroomInstaller') +cleanroomInstaller.canBeConsumed = false +cleanroomInstaller.canBeResolved = true +dependencies.add(cleanroomInstaller.name, "com.cleanroommc:cleanroom:${cleanroomVersion}:installer") { + transitive = false +} + +def productionJarTaskName = propertyBool('enable_shadow') ? 'remapShadowJar' : 'remapJar' +def productionJarTask = tasks.named(productionJarTaskName) +def minecraftConfig = unimined.minecrafts.get(sourceSets.main) +def productionNamespace = minecraftConfig.mcPatcher.prodNamespace + +def runtimeTestProductionMods = configurations.maybeCreate('runtimeTestProductionMods') +runtimeTestProductionMods.canBeConsumed = false +runtimeTestProductionMods.canBeResolved = true +runtimeTestProductionMods.transitive = false + +[configurations.modImplementation, configurations.modRuntimeOnly].each { sourceConfiguration -> + sourceConfiguration.dependencies.each { dependency -> + if (!(dependency instanceof ModuleDependency)) { + return + } + def productionNotation = [ + group: dependency.group, + name: dependency.name, + version: dependency.version + ] + if (!dependency.artifacts.empty) { + def requestedArtifact = dependency.artifacts.iterator().next() + if (requestedArtifact.classifier != null) { + productionNotation.classifier = requestedArtifact.classifier + } + if (requestedArtifact.extension != null) { + productionNotation.ext = requestedArtifact.extension + } + } + def productionDependency = project.dependencies.create( + productionNotation + ) + productionDependency.transitive = false + runtimeTestProductionMods.dependencies.add(productionDependency) + } +} +def runtimeTestModsDir = providers.gradleProperty('runtimeTestModsDir') + .map { file(it) } + .orElse(layout.buildDirectory.dir('runtime-test/instance/mods')) +def runtimeTestMinecraftDir = providers.gradleProperty('runtimeTestMinecraftDir') + .map { file(it) } + .orElse(layout.buildDirectory.dir('runtime-test/minecraft')) +def runtimeTestSupportDir = layout.buildDirectory.dir('runtime-test/support') +def runtimeTestClientModsDir = layout.buildDirectory.dir('runtime-test/client-mods') +def runtimeRemappedDir = layout.buildDirectory.dir('runtime-test/remapped-mods') +def runtimeMcpRemapMarker = layout.buildDirectory.file( + 'runtime-test/runtime-mcp-remap.marker' +) + +def runtimeProductionFiles = [] +def runtimeFallbackArtifacts = [] +def namespaceAttribute = Attribute.of( + 'com.gtnewhorizons.retrofuturagradle.obfuscation', + String +) + +def resolveProductionArtifact = { artifact -> + def moduleId = artifact.variant.owner + if (!(moduleId instanceof ModuleComponentIdentifier)) { + throw new GradleException( + "Runtime test artifact is not an external module: ${artifact.file}" + ) + } + + def productionDependency = project.dependencies.create([ + group: moduleId.group, + name: moduleId.module, + version: moduleId.version + ]) + productionDependency.transitive = false + def productionConfiguration = configurations.detachedConfiguration( + productionDependency + ) + productionConfiguration.transitive = false + productionConfiguration.attributes { + attribute(namespaceAttribute, 'srg') + } + def candidates = productionConfiguration.incoming.artifactView { + lenient true + }.artifacts.findAll { candidate -> + candidate.file.name.endsWith('.jar') + && !candidate.file.name.endsWith('-dev.jar') + && !candidate.file.name.endsWith('-sources.jar') + } + if (candidates.isEmpty()) { + return null + } + if (candidates.size() > 1) { + throw new GradleException( + "Multiple production artifacts resolved for ${moduleId}: " + + candidates.collect { it.file.name }.join(', ') + ) + } + candidates.iterator().next().file +} + +runtimeTestProductionMods.incoming.artifactView {}.artifacts.each { artifact -> + if (!artifact.file.name.endsWith('.jar') + || artifact.file.name.endsWith('-sources.jar')) { + return + } + + def artifactNamespace = artifact.variant.attributes.getAttribute(namespaceAttribute) + def isMcpArtifact = artifactNamespace == 'mcp' + def isDevArtifact = artifact.file.name.endsWith('-dev.jar') + if (!isMcpArtifact && !isDevArtifact) { + runtimeProductionFiles.add(artifact.file) + return + } + + def productionFile = resolveProductionArtifact(artifact) + if (productionFile == null) { + runtimeFallbackArtifacts.add(artifact) + } else { + runtimeProductionFiles.add(productionFile) + } +} + +def runtimeFallbackTasks = [] +def runtimeFallbackInputDir = layout.buildDirectory.dir( + 'runtime-test/inputs' +) +runtimeFallbackArtifacts.eachWithIndex { artifact, index -> + def inputTask = tasks.register("runtimeTestInput${index}", Jar) { + archiveFileName = "runtime-test-input-${index}.jar" + destinationDirectory = runtimeFallbackInputDir + from { zipTree(artifact.file) } + } + def remapTask = minecraftConfig.remap( + inputTask.get(), + "runtimeTestRemap${index}" + ) { + devNamespace 'mcp' + prodNamespace productionNamespace.name + mixinRemap { + enableMixinExtra() + disableRefmap() + } + } + remapTask.configure { + archiveFileName = artifact.file.name.replaceFirst( + '-dev(?=\\.jar$)', + '' + ) + destinationDirectory = runtimeRemappedDir + doFirst { + logger.lifecycle( + "[RuntimeTest] Remapping ${artifact.file.name} from mcp " + + "to ${productionNamespace.name}" + ) + } + doLast { + logger.lifecycle( + "[RuntimeTest] Finished remapping ${artifact.file.name}" + ) + } + } + runtimeFallbackTasks.add(remapTask) +} + +def runtimeMcpRemapTask = tasks.register('runtimeTestRemapMcp') { + dependsOn(runtimeFallbackTasks) + inputs.files(runtimeFallbackTasks.collect { remapTask -> + remapTask.flatMap { it.archiveFile } + }) + inputs.files(runtimeProductionFiles) + inputs.property('runtimeRemapSchema', 'runtime-production-variants-v2') + outputs.file(runtimeMcpRemapMarker) + doLast { + def remappedFiles = runtimeFallbackTasks.collect { remapTask -> + remapTask.get().archiveFile.get().asFile + } + runtimeMcpRemapMarker.get().asFile.text = ( + runtimeProductionFiles.collect { it.name } + + remappedFiles.collect { it.name } + ).sort().join('\n') + '\n' + if (remappedFiles.isEmpty()) { + project.delete(runtimeRemappedDir) + } + logger.lifecycle( + "[RuntimeTest] Production variants: ${runtimeProductionFiles.size()}, " + + "fallback remaps: ${remappedFiles.size()}" + ) + } +} + + + +tasks.register('stageRuntimeTestMods', Sync) { + dependsOn productionJarTask + dependsOn(runtimeMcpRemapTask) + from(productionJarTask.flatMap { it.archiveFile }) + from(runtimeProductionFiles) + runtimeFallbackTasks.each { remapTask -> + from(remapTask.flatMap { it.archiveFile }) + } + into(runtimeTestModsDir) + include '*.jar' + duplicatesStrategy = DuplicatesStrategy.FAIL +} + +tasks.register('stageRuntimeTestClientMods', Sync) { + dependsOn 'stageRuntimeTestMods' + from(runtimeTestSupportDir) { + include '*.jar' + } + into(runtimeTestClientModsDir) + include '*.jar' + duplicatesStrategy = DuplicatesStrategy.FAIL +} + +tasks.register('installRuntimeTestClient', JavaExec) { + dependsOn cleanroomInstaller + dependsOn 'stageRuntimeTestClientMods' + classpath = cleanroomInstaller + mainClass = 'net.minecraftforge.installer.SimpleInstaller' + def installDir = runtimeTestMinecraftDir.get().asFile + def profile = new File( + installDir, + "versions/${minecraftVersion}-Cleanroom-${cleanroomVersion}/" + + "${minecraftVersion}-Cleanroom-${cleanroomVersion}.json" + ) + def cleanroomJar = new File( + installDir, + "libraries/com/cleanroommc/cleanroom/${cleanroomVersion}/" + + "cleanroom-${cleanroomVersion}.jar" + ) + def marker = layout.buildDirectory.file('runtime-test/cleanroom-client-installed.marker').get().asFile + onlyIf { + !marker.exists() + || marker.text.trim() != "${minecraftVersion}-Cleanroom-${cleanroomVersion}" + || !profile.isFile() + || !cleanroomJar.isFile() + } + doFirst { + installDir.mkdirs() + def launcherProfiles = new File(installDir, 'launcher_profiles.json') + if (!launcherProfiles.exists()) { + launcherProfiles.text = '{"profiles":{},"selectedProfile":""}' + } + args '--install-client', installDir.absolutePath + } + doLast { + marker.parentFile.mkdirs() + marker.text = "${minecraftVersion}-Cleanroom-${cleanroomVersion}\n" + } +} + +tasks.register('printRuntimeTestPaths') { + doLast { + println "runtimeTestModsDir=${runtimeTestModsDir.get().absolutePath}" + println "runtimeTestMinecraftDir=${runtimeTestMinecraftDir.get().absolutePath}" + } +} + +spotless { + java { + target 'src/main/java/**/*.java' + leadingTabsToSpaces() + endWithNewline() + removeUnusedImports() + } +} diff --git a/gradle/scripts/helpers.gradle b/gradle/scripts/helpers.gradle new file mode 100644 index 0000000..dbfe20f --- /dev/null +++ b/gradle/scripts/helpers.gradle @@ -0,0 +1,97 @@ +import groovy.text.SimpleTemplateEngine +import org.codehaus.groovy.runtime.MethodClosure + +ext.propertyString = this.&propertyString as MethodClosure +ext.propertyBool = this.&propertyBool as MethodClosure +ext.propertyStringList = this.&propertyStringList as MethodClosure +ext.interpolate = this.&interpolate as MethodClosure +ext.assertProperty = this.&assertProperty as MethodClosure +ext.assertSubProperties = this.&assertSubProperties as MethodClosure +ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure +ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure + +String propertyString(String key) { + return $property(key).toString() +} + +boolean propertyBool(String key) { + return propertyString(key).toBoolean() +} + +Collection propertyStringList(String key) { + return propertyStringList(key, ' ') +} + +Collection propertyStringList(String key, String delimit) { + return propertyString(key).split(delimit).findAll { !it.isBlank() } +} + +private Object $property(String key) { + def value = project.findProperty(key) + if (value instanceof String) { + return interpolate(value) + } + return value +} + +String interpolate(String value) { + if (value.startsWith('${{') && value.endsWith('}}')) { + value = value.substring(3, value.length() - 2) + Binding newBinding = new Binding(this.binding.getVariables()) + newBinding.setProperty('it', this) + return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) + } + if (value.contains('${')) { + return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() + } + return value +} + +void assertProperty(String propertyName) { + def property = project.findProperty(propertyName) + if (property == null) { + throw new GradleException("Property ${propertyName} is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property ${propertyName} is empty!") + } +} + +void assertSubProperties(String propertyName, String... subPropertyNames) { + assertProperty(propertyName) + if (propertyBool(propertyName)) { + for (String subPropertyName : subPropertyNames) { + assertProperty(subPropertyName) + } + } +} + +void setDefaultProperty(String propertyName, boolean warn, defaultValue) { + def property = project.findProperty(propertyName) + def exists = true + if (property == null) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") + } + } else if (property.isEmpty()) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") + } + } + if (!exists) { + project.extensions.extraProperties.set(propertyName, defaultValue.toString()) + } +} + +@SuppressWarnings('GrMethodMayBeStatic') +void assertEnvironmentVariable(String propertyName) { + def property = System.getenv(propertyName) + if (property == null) { + throw new GradleException("System Environment Variable $propertyName is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property $propertyName is empty!") + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c61a118..7e7d24f 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-9.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 19e9d39..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -54,6 +54,7 @@ echo location of your Java installation. 1>&2 goto fail :findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..e2f4de4 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,7 @@ +jdk: + - openjdk25 + +install: + - sed -n '1,180p' ./scripts/install-jitpack-release.sh + - chmod +x ./scripts/install-jitpack-release.sh + - ./scripts/install-jitpack-release.sh diff --git a/scripts/install-jitpack-release.sh b/scripts/install-jitpack-release.sh new file mode 100644 index 0000000..15326a3 --- /dev/null +++ b/scripts/install-jitpack-release.sh @@ -0,0 +1,144 @@ +#!/usr/bin/env bash +set -euo pipefail + +version="${VERSION:-${RELEASE_TAG:-}}" +if [[ -z "${version}" ]]; then + echo "Missing VERSION or RELEASE_TAG" >&2 + exit 1 +fi + +if [[ -n "${GITHUB_REPOSITORY:-}" ]]; then + github_repository="${GITHUB_REPOSITORY}" +else + : "${GROUP:?Missing GROUP}" + : "${ARTIFACT:?Missing ARTIFACT}" + owner="${GROUP#com.github.}" + if [[ "${owner}" == "${GROUP}" || -z "${owner}" ]]; then + echo "GROUP must use JitPack's com.github. format, got: ${GROUP}" >&2 + exit 1 + fi + github_repository="${owner}/${ARTIFACT}" +fi + +target_repository="${MAVEN_LOCAL_REPOSITORY:-${HOME}/.m2/repository}" +temp_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}" + +if [[ -n "${RELEASE_TAG:-}" ]]; then + release_tag="${RELEASE_TAG}" +elif [[ "${version}" == v* ]]; then + release_tag="${version}" +else + release_tag="v${version}" +fi + +asset_name="${JITPACK_REPOSITORY_ASSET:-jitpack-repository-${release_tag}.zip}" +archive_path="${temp_dir}/${asset_name}" + +mkdir -p "$(dirname "${archive_path}")" "${target_repository}" + +if [[ -n "${GROUP:-}" ]]; then + group_path="${GROUP//./\/}" +else + owner="${github_repository%%/*}" + group_path="com/github/${owner}" +fi + +if [[ -n "${ARTIFACT:-}" ]]; then + artifact_id="${ARTIFACT}" +else + artifact_id="${github_repository##*/}" +fi + +expected_pom="${target_repository}/${group_path}/${artifact_id}/${version}/${artifact_id}-${version}.pom" +expected_dev_jar="${target_repository}/${group_path}/${artifact_id}/${version}/${artifact_id}-${version}-dev.jar" +expected_main_jar="${target_repository}/${group_path}/${artifact_id}/${version}/${artifact_id}-${version}.jar" +expected_sources_jar="${target_repository}/${group_path}/${artifact_id}/${version}/${artifact_id}-${version}-sources.jar" +expected_javadoc_jar="${target_repository}/${group_path}/${artifact_id}/${version}/${artifact_id}-${version}-javadoc.jar" +project_artifact_dir="${PWD}/build/libs" +project_repository_dir="${PWD}/build/jitpack-repository" +project_pom="${PWD}/build/pom.xml" +project_libs_pom="${project_artifact_dir}/pom.xml" +project_publication_pom="${PWD}/build/publications/mavenJava/pom-default.xml" + +download_release_asset() { + local tag="$1" + local name="$2" + local url="https://github.com/${github_repository}/releases/download/${tag}/${name}" + + echo "Downloading ${url}" + curl -fL -sS \ + --output "${archive_path}" \ + "${url}" +} + +if [[ -n "${JITPACK_REPOSITORY_URL:-}" ]]; then + echo "Downloading ${JITPACK_REPOSITORY_URL}" + curl -fL -sS \ + --output "${archive_path}" \ + "${JITPACK_REPOSITORY_URL}" +else + if ! download_release_asset "${release_tag}" "${asset_name}"; then + if [[ "${release_tag}" != "${version}" ]]; then + fallback_asset_name="jitpack-repository-${version}.zip" + archive_path="${temp_dir}/${fallback_asset_name}" + download_release_asset "${version}" "${fallback_asset_name}" + asset_name="${fallback_asset_name}" + else + exit 1 + fi + fi +fi + +echo "Installing JitPack repository into ${target_repository}" +echo "JitPack coordinates: ${group_path}/${artifact_id}/${version}" +echo "Working directory: ${PWD}" +if command -v git >/dev/null 2>&1; then + git rev-parse --show-toplevel || true +fi +mkdir -p \ + "${target_repository}" \ + "${project_repository_dir}" \ + "${project_artifact_dir}" \ + "${PWD}/build" \ + "$(dirname "${project_pom}")" \ + "$(dirname "${project_libs_pom}")" \ + "$(dirname "${project_publication_pom}")" +unzip -q -o "${archive_path}" -d "${target_repository}" +unzip -q -o "${archive_path}" -d "${project_repository_dir}" +missing_files=() +for expected_file in \ + "${expected_pom}" \ + "${expected_dev_jar}" \ + "${expected_main_jar}" \ + "${expected_sources_jar}" \ + "${expected_javadoc_jar}" +do + if [[ ! -f "${expected_file}" ]]; then + missing_files+=("${expected_file}") + fi +done + +if (( ${#missing_files[@]} > 0 )); then + echo "Expected installed artifacts not found:" >&2 + printf ' %s\n' "${missing_files[@]}" >&2 + find "${target_repository}" -maxdepth 8 -type f | sort | sed -n '1,80p' >&2 + exit 1 +fi + +cp "${expected_main_jar}" "${project_artifact_dir}/" +cp "${expected_dev_jar}" "${project_artifact_dir}/" +cp "${expected_sources_jar}" "${project_artifact_dir}/" +cp "${expected_javadoc_jar}" "${project_artifact_dir}/" +cp "${expected_main_jar}" "${PWD}/build/" +cp "${expected_dev_jar}" "${PWD}/build/" +cp "${expected_sources_jar}" "${PWD}/build/" +cp "${expected_javadoc_jar}" "${PWD}/build/" +cp "${expected_pom}" "${project_pom}" +cp "${expected_pom}" "${project_libs_pom}" +cp "${expected_pom}" "${project_publication_pom}" + +echo "Installed project build artifacts:" +find "${PWD}/build" -maxdepth 4 -type d | sort | sed -n '1,80p' +find "${PWD}/build" -maxdepth 8 -type f | sort | sed -n '1,120p' + +find "${target_repository}" -maxdepth 8 -type f | sort | sed -n '1,80p' \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 0191728..11fcf1c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,7 +16,7 @@ pluginManagement { url = 'https://maven.wagyourtail.xyz/releases' } maven { - url = 'https://maven.arcseekers.com/releases' + url = 'https://maven.outlands.top/releases' } maven { diff --git a/src/main/java-templates/com/formlesslab/ae2additions/Reference.java b/src/main/java-templates/com/formlesslab/ae2additions/Reference.java deleted file mode 100644 index 28b38f1..0000000 --- a/src/main/java-templates/com/formlesslab/ae2additions/Reference.java +++ /dev/null @@ -1,13 +0,0 @@ -package {{ package }}; - -/** - * Tags storage class, you can change at will - */ -public class Reference { - private Reference() {} - - public static final String MOD_ID = "{{ mod_id }}"; - public static final String MOD_NAME = "{{ mod_name }}"; - public static final String VERSION = "{{ mod_version }}"; - -} diff --git a/src/main/java/com/formlesslab/ae2additions/AppliedAdditions.java b/src/main/java/com/formlesslab/ae2additions/AppliedAdditions.java index 806ea11..082f50a 100644 --- a/src/main/java/com/formlesslab/ae2additions/AppliedAdditions.java +++ b/src/main/java/com/formlesslab/ae2additions/AppliedAdditions.java @@ -19,11 +19,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions = "[1.12.2]", dependencies = "required-after:ae2") +@Mod(modid = Tags.MOD_ID, name = Tags.MOD_NAME, version = Tags.VERSION, acceptedMinecraftVersions = "[1.12.2]", dependencies = "required-after:ae2") public class AppliedAdditions { - public static final Logger LOGGER = LogManager.getLogger(Reference.MOD_NAME); - @Mod.Instance(Reference.MOD_ID) + public static final Logger LOGGER = LogManager.getLogger(Tags.MOD_NAME); + @Mod.Instance(Tags.MOD_ID) public static AppliedAdditions INSTANCE; static { @@ -41,7 +41,7 @@ public void preInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(QuantumComputerModelOverride.INSTANCE); MinecraftForge.EVENT_BUS.register(WirelessHighlightHandler.INSTANCE); } - LOGGER.info("{} initialized", Reference.MOD_NAME); + LOGGER.info("{} initialized", Tags.MOD_NAME); } @Mod.EventHandler diff --git a/src/main/java/com/formlesslab/ae2additions/api/AAECraftingUnitType.java b/src/main/java/com/formlesslab/ae2additions/api/AAECraftingUnitType.java index 853a6d1..465116f 100644 --- a/src/main/java/com/formlesslab/ae2additions/api/AAECraftingUnitType.java +++ b/src/main/java/com/formlesslab/ae2additions/api/AAECraftingUnitType.java @@ -3,7 +3,7 @@ import ae2.api.crafting.cpu.CraftingUnitVisualDefinition; import ae2.api.crafting.cpu.CraftingUnitVisualKind; import ae2.block.crafting.ICraftingUnitType; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.init.Configurations; import com.formlesslab.ae2additions.init.ModContent; import net.minecraft.item.Item; @@ -23,12 +23,12 @@ public enum AAECraftingUnitType implements ICraftingUnitType { AAECraftingUnitType(String registryName, int storageMb) { this.registryName = registryName; this.storageMb = storageMb; - this.id = new ResourceLocation(Reference.MOD_ID, registryName); - this.visualDefinition = CraftingUnitVisualDefinition.builder(CraftingUnitVisualKind.CUSTOM, new ResourceLocation(Reference.MOD_ID, "quantum_crafting/" + registryName), new ResourceLocation(Reference.MOD_ID, "quantum_crafting/" + registryName + "_formed")).ringTextures(new ResourceLocation(Reference.MOD_ID, "block/quantum_crafting/quantum_structure_formed_face"), new ResourceLocation(Reference.MOD_ID, "block/quantum_crafting/quantum_structure_formed_sides"), new ResourceLocation(Reference.MOD_ID, "block/quantum_crafting/quantum_structure_formed_sides")).formedModelProviderId(quantumComputerId()).build(); + this.id = new ResourceLocation(Tags.MOD_ID, registryName); + this.visualDefinition = CraftingUnitVisualDefinition.builder(CraftingUnitVisualKind.CUSTOM, new ResourceLocation(Tags.MOD_ID, "quantum_crafting/" + registryName), new ResourceLocation(Tags.MOD_ID, "quantum_crafting/" + registryName + "_formed")).ringTextures(new ResourceLocation(Tags.MOD_ID, "block/quantum_crafting/quantum_structure_formed_face"), new ResourceLocation(Tags.MOD_ID, "block/quantum_crafting/quantum_structure_formed_sides"), new ResourceLocation(Tags.MOD_ID, "block/quantum_crafting/quantum_structure_formed_sides")).formedModelProviderId(quantumComputerId()).build(); } private static ResourceLocation quantumComputerId() { - return new ResourceLocation(Reference.MOD_ID, "quantum_computer"); + return new ResourceLocation(Tags.MOD_ID, "quantum_computer"); } public String getRegistryName() { diff --git a/src/main/java/com/formlesslab/ae2additions/client/model/AAECraftingUnitModelProvider.java b/src/main/java/com/formlesslab/ae2additions/client/model/AAECraftingUnitModelProvider.java index 9855095..c42deba 100644 --- a/src/main/java/com/formlesslab/ae2additions/client/model/AAECraftingUnitModelProvider.java +++ b/src/main/java/com/formlesslab/ae2additions/client/model/AAECraftingUnitModelProvider.java @@ -2,7 +2,7 @@ import ae2.api.client.crafting.ICraftingUnitModelProvider; import ae2.api.crafting.cpu.ICraftingUnitDefinition; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.api.AAECraftingUnitType; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -34,7 +34,7 @@ public static Collection getTextures() { } private static ResourceLocation texture(String name) { - return new ResourceLocation(Reference.MOD_ID, "block/quantum_crafting/" + name); + return new ResourceLocation(Tags.MOD_ID, "block/quantum_crafting/" + name); } private static AAECraftingUnitType resolveType(ICraftingUnitDefinition definition) { diff --git a/src/main/java/com/formlesslab/ae2additions/client/render/QuantumComputerModelOverride.java b/src/main/java/com/formlesslab/ae2additions/client/render/QuantumComputerModelOverride.java index 5e41595..ce43e47 100644 --- a/src/main/java/com/formlesslab/ae2additions/client/render/QuantumComputerModelOverride.java +++ b/src/main/java/com/formlesslab/ae2additions/client/render/QuantumComputerModelOverride.java @@ -1,7 +1,7 @@ package com.formlesslab.ae2additions.client.render; import ae2.core.registries.CraftingUnitClientRegistry; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.api.AAECraftingUnitType; import com.formlesslab.ae2additions.client.model.AAECraftingUnitModelProvider; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -17,7 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; -@Mod.EventBusSubscriber(modid = Reference.MOD_ID, value = Side.CLIENT) +@Mod.EventBusSubscriber(modid = Tags.MOD_ID, value = Side.CLIENT) public final class QuantumComputerModelOverride { public static final QuantumComputerModelOverride INSTANCE = new QuantumComputerModelOverride(); @@ -32,7 +32,7 @@ private static void putFormedVariant(IRegistry registry, String path, String variant, IBakedModel model) { - registry.putObject(new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, path), variant), model); + registry.putObject(new ModelResourceLocation(new ResourceLocation(Tags.MOD_ID, path), variant), model); } @SubscribeEvent diff --git a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberJeiPlugin.java b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberJeiPlugin.java index 971812c..4bbd4af 100644 --- a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberJeiPlugin.java +++ b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberJeiPlugin.java @@ -1,6 +1,6 @@ package com.formlesslab.ae2additions.compat.jei; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.client.gui.GuiReactionChamber; import com.formlesslab.ae2additions.init.ModContent; import com.formlesslab.ae2additions.init.ModRecipes; @@ -14,7 +14,7 @@ @JEIPlugin public class ReactionChamberJeiPlugin implements IModPlugin { - public static final String REACTION_CHAMBER_UID = Reference.MOD_ID + ".reaction_chamber"; + public static final String REACTION_CHAMBER_UID = Tags.MOD_ID + ".reaction_chamber"; @Override public void registerCategories(IRecipeCategoryRegistration registry) { diff --git a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeCategory.java b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeCategory.java index e3f9fc7..85e0ab8 100644 --- a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeCategory.java +++ b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeCategory.java @@ -1,6 +1,6 @@ package com.formlesslab.ae2additions.compat.jei; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.init.ModContent; import com.formlesslab.ae2additions.tile.TileReactionChamber; import mezz.jei.api.IGuiHelper; @@ -15,7 +15,7 @@ import org.jspecify.annotations.NonNull; public class ReactionChamberRecipeCategory implements IRecipeCategory { - private static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID, "textures/guis/reaction_chamber.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(Tags.MOD_ID, "textures/guis/reaction_chamber.png"); private final IDrawable background; private final IDrawable icon; private final IDrawableAnimated progress; @@ -39,7 +39,7 @@ public String getTitle() { @Override public String getModName() { - return Reference.MOD_NAME; + return Tags.MOD_NAME; } @Override diff --git a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeWrapper.java b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeWrapper.java index c574305..ffaa791 100644 --- a/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeWrapper.java +++ b/src/main/java/com/formlesslab/ae2additions/compat/jei/ReactionChamberRecipeWrapper.java @@ -1,6 +1,6 @@ package com.formlesslab.ae2additions.compat.jei; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.recipe.ReactionChamberRecipe; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; @@ -18,7 +18,7 @@ import java.util.List; public class ReactionChamberRecipeWrapper implements IRecipeWrapper { - private static final ResourceLocation BOLT_TEXTURE = new ResourceLocation(Reference.MOD_ID, "textures/guis/emi.png"); + private static final ResourceLocation BOLT_TEXTURE = new ResourceLocation(Tags.MOD_ID, "textures/guis/emi.png"); private final ReactionChamberRecipe recipe; private final FluidStack inputFluid; diff --git a/src/main/java/com/formlesslab/ae2additions/fluid/QuantumInfusionFluid.java b/src/main/java/com/formlesslab/ae2additions/fluid/QuantumInfusionFluid.java index 921c9d1..a0865f8 100644 --- a/src/main/java/com/formlesslab/ae2additions/fluid/QuantumInfusionFluid.java +++ b/src/main/java/com/formlesslab/ae2additions/fluid/QuantumInfusionFluid.java @@ -1,6 +1,6 @@ package com.formlesslab.ae2additions.fluid; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import net.minecraft.block.material.Material; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.BlockFluidClassic; @@ -28,7 +28,7 @@ public QuantumInfusionBlock() { @Override public String getTranslationKey() { - return "tile." + Reference.MOD_ID + ".quantum_infusion_block"; + return "tile." + Tags.MOD_ID + ".quantum_infusion_block"; } } } diff --git a/src/main/java/com/formlesslab/ae2additions/init/Configurations.java b/src/main/java/com/formlesslab/ae2additions/init/Configurations.java index c0c0e82..c0088bd 100644 --- a/src/main/java/com/formlesslab/ae2additions/init/Configurations.java +++ b/src/main/java/com/formlesslab/ae2additions/init/Configurations.java @@ -1,15 +1,15 @@ package com.formlesslab.ae2additions.init; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import net.minecraftforge.common.config.Config; import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -@Config(modid = Reference.MOD_ID, name = Reference.MOD_ID, category = "") +@Config(modid = Tags.MOD_ID, name = Tags.MOD_ID, category = "") @Config.LangKey("config.ae2additions") -@Mod.EventBusSubscriber(modid = Reference.MOD_ID) +@Mod.EventBusSubscriber(modid = Tags.MOD_ID) public final class Configurations { @Config.Name("wireless") @@ -33,8 +33,8 @@ private Configurations() { @SubscribeEvent public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { - if (Reference.MOD_ID.equals(event.getModID())) { - ConfigManager.sync(Reference.MOD_ID, Config.Type.INSTANCE); + if (Tags.MOD_ID.equals(event.getModID())) { + ConfigManager.sync(Tags.MOD_ID, Config.Type.INSTANCE); } } diff --git a/src/main/java/com/formlesslab/ae2additions/init/ModContent.java b/src/main/java/com/formlesslab/ae2additions/init/ModContent.java index 8f230de..c0e13ea 100644 --- a/src/main/java/com/formlesslab/ae2additions/init/ModContent.java +++ b/src/main/java/com/formlesslab/ae2additions/init/ModContent.java @@ -8,7 +8,7 @@ import ae2.recipes.AERecipeTypes; import ae2.recipes.handlers.InscriberProcessType; import ae2.recipes.handlers.InscriberRecipe; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.api.AAECraftingUnitType; import com.formlesslab.ae2additions.block.assembler.*; import com.formlesslab.ae2additions.block.material.*; @@ -50,7 +50,7 @@ import java.util.*; import java.util.function.Supplier; -@Mod.EventBusSubscriber(modid = Reference.MOD_ID) +@Mod.EventBusSubscriber(modid = Tags.MOD_ID) public final class ModContent { public static final Item QUANTUM_INFUSED_DUST; public static final CreativeTabs CREATIVE_TAB; @@ -256,7 +256,7 @@ private static ItemStack registerBuiltinInfinityCell(String name, Collection tileClass, Str private static T setupBlock(T block, String name) { block.setRegistryName(id(name)); - block.setTranslationKey(Reference.MOD_ID + "." + name); + block.setTranslationKey(Tags.MOD_ID + "." + name); block.setCreativeTab(CREATIVE_TAB); if (!(block instanceof BlockQuantumAlloyBlock) && !(block instanceof BlockQuantumAlloyStairs) && !(block instanceof BlockQuantumAlloyWall) && !(block instanceof BlockQuantumAlloySlab) && !(block instanceof BlockQuantumAlloyDoubleSlab)) { block.setHardness(2.2F); @@ -337,7 +337,7 @@ private static Item setupBlockItem(Block block, String name) { item = new ItemBlock(block); } item.setRegistryName(id(name)); - item.setTranslationKey(Reference.MOD_ID + "." + name); + item.setTranslationKey(Tags.MOD_ID + "." + name); return item; } diff --git a/src/main/java/com/formlesslab/ae2additions/init/ModNetworks.java b/src/main/java/com/formlesslab/ae2additions/init/ModNetworks.java index fd90810..8757c52 100644 --- a/src/main/java/com/formlesslab/ae2additions/init/ModNetworks.java +++ b/src/main/java/com/formlesslab/ae2additions/init/ModNetworks.java @@ -1,6 +1,6 @@ package com.formlesslab.ae2additions.init; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.network.CAssemblerMatrixCancel; import com.formlesslab.ae2additions.network.CAssemblerMatrixPatternMode; import com.formlesslab.ae2additions.network.CReactionChamberOutputSides; @@ -13,7 +13,7 @@ import net.minecraftforge.fml.relauncher.Side; public final class ModNetworks { - public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID); + public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(Tags.MOD_ID); public static final int QUANTUM_TASK_CANCEL = 0; public static final int QUANTUM_CPU_SELECTION = 1; diff --git a/src/main/java/com/formlesslab/ae2additions/item/ItemInfinityCell.java b/src/main/java/com/formlesslab/ae2additions/item/ItemInfinityCell.java index 6d7d1c4..e38cc20 100644 --- a/src/main/java/com/formlesslab/ae2additions/item/ItemInfinityCell.java +++ b/src/main/java/com/formlesslab/ae2additions/item/ItemInfinityCell.java @@ -6,7 +6,7 @@ import ae2.api.storage.cells.IStackTooltipDataProvider; import ae2.items.AEBaseItem; import ae2.items.storage.StorageCellTooltipComponent; -import com.formlesslab.ae2additions.Reference; +import com.formlesslab.ae2additions.Tags; import com.formlesslab.ae2additions.cell.InfinityCellContents; import com.formlesslab.ae2additions.init.ModContent; import net.minecraft.client.util.ITooltipFlag; @@ -37,14 +37,14 @@ public String getItemStackDisplayName(ItemStack stack) { List keys = InfinityCellContents.readKeys(stack); if (keys.size() == 1) { - return new TextComponentTranslation("item." + Reference.MOD_ID + ".infinity_cell.name", keys.getFirst().getDisplayName()).getFormattedText(); + return new TextComponentTranslation("item." + Tags.MOD_ID + ".infinity_cell.name", keys.getFirst().getDisplayName()).getFormattedText(); } - return new TextComponentTranslation("item." + Reference.MOD_ID + ".infinity_cell.multiple.name").getFormattedText(); + return new TextComponentTranslation("item." + Tags.MOD_ID + ".infinity_cell.multiple.name").getFormattedText(); } @Override protected void addCheckedInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.GREEN + new TextComponentTranslation("tooltip." + Reference.MOD_ID + ".infinity_cell").getFormattedText()); + tooltip.add(TextFormatting.GREEN + new TextComponentTranslation("tooltip." + Tags.MOD_ID + ".infinity_cell").getFormattedText()); } @Override diff --git a/src/main/java/com/formlesslab/ae2additions/recipe/NonCraftingRecipe.java b/src/main/java/com/formlesslab/ae2additions/recipe/NonCraftingRecipe.java index 3d1dd49..f116237 100644 --- a/src/main/java/com/formlesslab/ae2additions/recipe/NonCraftingRecipe.java +++ b/src/main/java/com/formlesslab/ae2additions/recipe/NonCraftingRecipe.java @@ -38,4 +38,4 @@ public NonNullList getRemainingItems(InventoryCrafting inv) { public boolean isDynamic() { return true; } -} \ No newline at end of file +} diff --git a/src/main/resource-templates/mcmod.info b/src/main/resource-templates/mcmod.info deleted file mode 100644 index fbf78e1..0000000 --- a/src/main/resource-templates/mcmod.info +++ /dev/null @@ -1,12 +0,0 @@ -[{ - "modid": "{{ mod_id }}", - "name": "{{ mod_name }}", - "version": "{{ mod_version }}", - "mcversion": "1.12.2", - "description": "{{ mod_description }}", - "authorList": [{{ mod_authors }}], - "credits": "{{ mod_credits }}", - "url": "{{ mod_url }}", - "updateJSON": "{{ mod_update_json }}", - "logoFile": "{{ mod_logo_path }}" -}] \ No newline at end of file diff --git a/src/main/resource-templates/pack.mcmeta b/src/main/resource-templates/pack.mcmeta deleted file mode 100644 index 51e635d..0000000 --- a/src/main/resource-templates/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "{{ mod_name }} Resources", - "pack_format": 3 - } -} \ No newline at end of file