English Version | 中文版
This is a modern development template for creating Minecraft 1.20.1+ NeoForge Mods, integrated with popular libraries and tools to simplify the mod development process.
- Support for Minecraft 1.20.1+ and NeoForge
- Integration with popular mod development libraries (JEI, GeckoLib, Curios, etc.)
- Automated build and publishing pipeline
- Support for Modrinth and CurseForge publishing
- Flexible dependency management system
- Complete development environment configuration
- Java 17 JDK - Java 17 Development Kit is required
- IntelliJ IDEA - Recommended IDE for development
- Git - Version control tool
Choose one of the following methods to get the template:
Method 1: Download ZIP File
- Click the "Code" button at the top right of the page
- Select "Download ZIP"
- Extract to your development directory
Method 2: Clone Repository
git clone [repository-url]
cd PickAIDForgeTemplateOpen the build.txt file and modify the following essential information:
# Mod Basic Information
mod_id=your_mod_id
mod_name=Your Mod Name
mod_description=Mod description
mod_authors=Author Name
mod_license=MIT
# Maven Repository Configuration (Optional)
maven_group=com.yourname.yourmod
maven_url=your_maven_repository_url
# Project IDs (Optional, for automatic publishing)
cf_project=CurseForge_Project_ID
modrinth_project=Modrinth_Project_IDImportant: You must modify the following files to properly develop your Mod
-
Rename Package Structure:
- Rename the
src/main/java/org/pickaid/modid/directory to your package structure - For example:
src/main/java/com/yourname/yourmod/
- Rename the
-
Modify Main Class File: Edit
Example.java(or rename it to your main class name):package com.yourname.yourmod; // Modify package name import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.common.Mod; @Mod(YourModName.MOD_ID) public class YourModName // Modify class name { public static final String MOD_ID = "yourmodid"; // Change to your mod_id public static ResourceLocation id(String path) { return new ResourceLocation(MOD_ID, path); } }
-
Rename Mixin Directory:
- Rename
src/main/java/org/pickaid/modid/mixins/to mixins under your package path
- Rename
-
Modify Mixin Configuration File: Edit
src/main/resources/mixins.modid.json:{ "required": true, "priority": 800, "minVersion": "0.8", "package": "com.yourname.yourmod.mixins", // Modify package path "refmap": "yourmod.refmap.json", // Modify refmap name "compatibilityLevel": "JAVA_17", "mixins": [], "client": [], "server": [] } -
Rename Mixin Configuration File:
- Rename
mixins.modid.jsontomixins.yourmodid.json
- Rename
Important: mods.toml has been optimized and usually doesn't need manual modification
The src/main/resources/META-INF/mods.toml file in the template has been modernized:
- Automatic Variable Substitution: All configurations are automatically filled from
build.txt - Clear Structure: Divided into core dependencies and optional dependencies
- Correct Version Ranges: Dependencies use proper version number formats
- Comprehensive Comments: Easy to understand the purpose of each configuration
To enable optional dependencies (like JEI, Curios, etc.), simply:
- Uncomment the corresponding version configuration in
build.txt - Uncomment the corresponding dependency in
mods.toml
Important Notes:
- mods.toml now uses variable substitution, no need to manually edit version numbers
- All version numbers are centrally managed in
build.txt - Ensure both build.gradle and mods.toml are synchronized when enabling dependencies
accesstransformer.cfg File:
- Used for access transformer configuration, usually kept empty
- Add AT rules here if you need to modify private fields or methods
-
Rename Assets Folder:
- Rename
src/main/resources/assets/modid/tosrc/main/resources/assets/yourmodid/
- Rename
-
Optional: Modify Mod Icon:
- change
icon.pngin thesrc/main/resources/directory as the mod icon (64x64 pixels)
- change
- Open the
build.gradlefile in the project root directory with IntelliJ IDEA - Select "Open as Project"
- Wait for Gradle synchronization to complete
- Run
./gradlew genEclipseRunsor./gradlew genIntellijRunsto generate run configurations
Before starting development, make sure you have completed all of the following steps:
- Modify basic information in
build.txt(mod_id, mod_name, mod_authors, etc.) - Rename Java package structure (from
org.pickaid.modidto your package name) - Modify package name, class name, and MOD_ID in the main class file
- Rename and modify Mixin configuration file
mixins.modid.json - Update package path in Mixin configuration
- Check
mods.tomlconfiguration (usually auto-generated, no modification needed) - Optional: Enable required dependencies in
mods.toml - Rename assets resource folder (from
modidto your mod id) - Optional: Add mod icon file
- Run
./gradlew buildto ensure the project compiles successfully
This template supports configuring sensitive information through environment variables, such as Maven repository credentials and publishing tokens.
The following environment variables are supported (higher priority than configuration file):
MAVEN_URL- Maven repository URLMAVEN_USER- Maven usernameMAVEN_PASSWORD- Maven password
MODRINTH_TOKEN- Modrinth publishing tokenCURSEFORGE_TOKEN- CurseForge publishing token
Method 1: Through System Settings
- Press
Win + Rto open the Run dialog - Type
rundll32 sysdm.cpl,EditEnvironmentVariablesand press Enter - Click "New" in the "User Variables" or "System Variables" section
- Enter the variable name and value
- Click "OK" to save settings
- Restart the computer to apply settings
Method 2: Through Command Line (Temporary)
set MAVEN_USER=your_username
set MAVEN_PASSWORD=your_password
set MODRINTH_TOKEN=your_tokenMethod 3: Through PowerShell (Persistent)
[Environment]::SetEnvironmentVariable("MAVEN_USER", "your_username", "User")
[Environment]::SetEnvironmentVariable("MAVEN_PASSWORD", "your_password", "User")
[Environment]::SetEnvironmentVariable("MODRINTH_TOKEN", "your_token", "User")Method 1: Temporary Setup
export MAVEN_USER="your_username"
export MAVEN_PASSWORD="your_password"
export MODRINTH_TOKEN="your_token"Method 2: Permanent Setup
Edit ~/.bashrc or ~/.profile file:
echo 'export MAVEN_USER="your_username"' >> ~/.bashrc
echo 'export MAVEN_PASSWORD="your_password"' >> ~/.bashrc
echo 'export MODRINTH_TOKEN="your_token"' >> ~/.bashrc
source ~/.bashrcMethod 1: Temporary Setup
export MAVEN_USER="your_username"
export MAVEN_PASSWORD="your_password"
export MODRINTH_TOKEN="your_token"Method 2: Permanent Setup
Edit ~/.zshrc (or ~/.bash_profile, depending on your shell):
echo 'export MAVEN_USER="your_username"' >> ~/.zshrc
echo 'export MAVEN_PASSWORD="your_password"' >> ~/.zshrc
echo 'export MODRINTH_TOKEN="your_token"' >> ~/.zshrc
source ~/.zshrcThe template supports various popular mod development libraries. Uncomment the corresponding configuration in build.txt to enable:
jei_version=15.2.0.27geckolib_version=4.4.9curios_version=5.9.1+1.20.1playeranimator_version=1.0.2+1.20citadel_version=2.5.4# L2 Series Libraries
l2_library_version=2.5.1-slim
l2damagetracker_version=0.3.7
l2serial_version=1.2.2
# Mixin Extensions
mixin_extras_version=0.2.0-beta.8# Build Mod
./gradlew build
# Build and Sign (requires signing environment variables)
./gradlew signJar# Publish to Modrinth and CurseForge
./gradlew buildAndUploadMod- When
formal_versionis set totrue, each build will automatically increment the version number - When
formal_versionis set tofalse, use the fixed version number in the configuration file
The template provides the following run configurations:
- client - Client testing environment
- server - Server testing environment
- data - Data generation tool
- gameTestServer - Game test server
src/main/
├── java/ # Java source code
├── resources/
│ ├── META-INF/ # Mod metadata
│ ├── assets/ # Resource files (textures, models, etc.)
│ └── data/ # Data files (recipes, loot tables, etc.)
└── generated/ # Auto-generated data files
- Use
./gradlew runClientto start client testing - Use
./gradlew runServerto start server testing - Use
./gradlew runDatato generate data files
-
Build Failed: Java 17 Not Found
- Ensure Java 17 JDK is installed
- Check
JAVA_HOMEenvironment variable setting
-
Gradle Sync Failed
- Check network connection
- Try cleaning Gradle cache:
./gradlew clean
-
Run Configurations Lost
- Regenerate run configurations:
./gradlew genIntellijRuns
- Regenerate run configurations:
-
Mixin Error: Class or Package Not Found
- Check if the package path in
mixins.yourmodid.jsonis correct - Ensure Mixin class package names match the configuration file
- Verify Mixin configuration in
build.gradleis correct
- Check if the package path in
-
Resource File Loading Failed
- Ensure
assets/yourmodid/folder name matches your mod_id - Check if resource file paths are correct
- Ensure
-
Main Class Annotation Error
- Ensure the value in
@Modannotation matchesmod_idinbuild.txt - Check if
MOD_IDconstant in main class is correct
- Ensure the value in
-
mods.toml Configuration Issues
- Check if variables in
build.txtare correctly filled - Ensure dependency version variables are defined and uncommented in
build.txt - Verify
displayURLandupdateJSONURLconfigurations are valid - If dependencies are enabled but build fails, check if corresponding gradle dependencies are also enabled
- Check if variables in
-
Publishing Failed
- Check environment variable configuration
- Verify project ID settings
Note
Since the nf gradle for 1.20.1 is essentially still forge, you generally need to seek help from Forge developers.
- Check Forge Official Documentation
- Check NeoForge Official Documentation
- Visit NeoForge Discord
- Submit an Issue
This template is released under the MIT License. You are free to use, modify, and distribute it.
Thanks to the following projects and developers for their contributions:
- NeoForge Team
- Minecraft Forge Community
- Developers of various dependency libraries
Start your mod development journey!