JIT
Minecraft 1.21 Forge AutoTool Mod
Create a mod for Minecraft 1.21 forge, forge version 51.0.33, my nickname is Nort8985, make an AutoTool mod, full client side.
Updated files
v1
delete everything you don't need

Okay, I've reviewed the project structure. For the AutoTool mod as described (client-side, automatically selecting the best tool on left-click), all the existing files (build.gradle, gradle.properties, mods.toml, AutoToolMod.java, ClientEventHandler.java, ToolSelector.java) are necessary for it to build and function correctly.

There are no extra files or code components to remove at this stage. The current setup is the minimal required structure for this Forge mod.

make a normal AutoTool mod

Okay, I've refined the tool selection logic slightly for clarity and robustness. This implementation represents a standard, client-side AutoTool mod that switches to the best tool in your hotbar when you start breaking a block.

This version maintains the core functionality but refines the ToolSelector logic slightly and ensures the event handler uses the correct event bus and checks.

Updated files
v2
Are all the files ready? if not, add all the necessary files to compile gradle.

You are correct! While the core mod code and configuration were provided, the standard Gradle wrapper files needed for building the project were missing. I'll add those now, along with a basic pack.mcmeta file.

Now the project includes the necessary Gradle wrapper scripts (gradlew, gradlew.bat, gradle/wrapper/gradle-wrapper.properties) and the pack.mcmeta file. This structure should be complete and allow you to compile the mod using Gradle commands like ./gradlew build.

Updated files
v3
just Forge, not NeoForge, forge version 51.0.33

Okay, I understand. You want to use the traditional Minecraft Forge modding platform instead of NeoForge, targeting Forge version 51.0.33 for Minecraft 1.21.

I will now update the project files to reflect this change, adjusting the build script, dependencies, imports, and metadata accordingly.

Key changes made:

  • build.gradle: Switched to net.minecraftforge.gradle plugin, updated dependency format to net.minecraftforge:forge:..., adjusted minecraft block and runs configuration for Forge standards.
  • mods.toml: Updated loaderVersion for Forge 51+, adjusted dependency modId and versionRange for Forge, and added a [[mixins]] entry to properly declare the mod as client-side (even though we aren't adding actual mixins yet).
  • Java Imports: Changed all net.neoforged.* imports to their net.minecraftforge.* equivalents.
  • Event Handling: Updated event bus registration in AutoToolMod.java to use MinecraftForge.EVENT_BUS and FMLJavaModLoadingContext. Changed ClientEventHandler to use @Mod.EventBusSubscriber.
  • pack.mcmeta: Updated pack_format to 34 for Minecraft 1.21 and removed the NeoForge-specific supported_formats.
  • Added an empty mixin config (autotool.mixins.json) and package structure, as referenced in mods.toml for side declaration.

This setup should now correctly configure and build the AutoTool mod using the specified Minecraft Forge version._

Updated files
v4
remove all comments from all files, and never write them again.

Okay, I will remove all comments from the project files.

Updated files
v5
.../Download/autotool $ gradle build FAILURE: Build failed with an exception. * Where: Build file '/storage/emulated/0/Download/autotool/build.gradle' line: 2 * What went wrong: Plugin [id: 'net.minecraftforge.gradle', version: '6.0.+'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Included Builds (No included builds contain this plugin) - Plugin Repositories (could not resolve plugin artifact 'net.minecraftforge.gradle:net.minecraftforge.gradle.gradle.plugin:6.0.+') Searched in the following repositories: Gradle Central Plugin Repository * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 9s .../Download/autotool $

Ah, it seems we missed adding the necessary repository for Gradle to find the net.minecraftforge.gradle plugin. We need to create a settings.gradle file to tell Gradle where to look.

Adding the settings.gradle file with the pluginManagement block pointing to the Forge Maven repository should resolve the plugin not found error. Try running ./gradlew build again.

Updated files
v6
build.gradle

gradle plugins { id 'net.minecraftforge.gradle' version '6.0.+' }

version = mod_version group = "com.nort8985.${mod_id}" base.archivesName = mod_id

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: System.getPropertyjava.version,JVM:{System.getProperty 'java.version'}, JVM: {System.getProperty 'java.vm.version'} (System.getPropertyjava.vendor),Arch:{System.getProperty 'java.vendor'}), Arch: {System.getProperty 'os.arch'}"

minecraft { mappings channel: mapping_channel, version: mapping_version

runs {
    client {
        workingDirectory project.file('run')
        property 'forge.logging.markers', 'REGISTRIES'
        property 'forge.logging.console.level', 'debug'
        mods {
            "${mod_id}" {
                source sourceSets.main
            }
        }
    }

    server {
        workingDirectory project.file('run')
        property 'forge.logging.markers', 'REGISTRIES'
        property 'forge.logging.console.level', 'debug'
        mods {
            "${mod_id}" {
                source sourceSets.main
            }
        }
    }

    data {
        workingDirectory project.file('run')
        property 'forge.logging.markers', 'REGISTRIES'
        property 'forge.logging.console.level', 'debug'
        mods {
            "${mod_id}" {
                source sourceSets.main
            }
        }
        args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
    }
}

}

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories { }

dependencies { minecraft "net.minecraftforge:forge:minecraftversion{minecraft_version}-{forge_version}" }

jar { manifest { attributes([ "Specification-Title" : mod_id, "Specification-Vendor" : mod_author, "Specification-Version" : "1", "Implementation-Title" : project.name, "Implementation-Version" : project.jar.archiveVersion, "Implementation-Vendor" : mod_author, "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } }

jar.finalizedBy('reobfJar')

tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' }

build.gradle plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0.24,6.2)' } version = mod_version group = mod_group_id base { archivesName = mod_id } java.toolchain.languageVersion = JavaLanguageVersion.of(21) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version reobf = false copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' } client { property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.jetbrains:annotations:24.0.1' } tasks.named('processResources', ProcessResources).configure { var replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description, ] inputs.properties replaceProperties filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { expand replaceProperties + [project: project] } } tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors ]) } } publishing { publications { register('mavenJava', MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' } idea.module { downloadJavadoc = downloadSources = true } eclipse { synchronizationTasks 'genEclipseRuns' } sourceSets.each { def dir = layout.buildDirectory.dir("sourcesSets/$it.name") it.output.resourcesDir = dir it.java.destinationDirectory = dir }