1. Install Java and Required Tools
Download and install the latest Java Development Kit version 17 from the official Oracle website. Set the JAVA_HOME environment variable to point to your installation directory on your computer system. Verify the installation by opening a terminal and running java -version to confirm the correct version appears. This setup ensures your build tools can compile and run your mod code without errors later. You see the version number print clearly in your terminal window output.
2. Set Up Your Modding Workspace
Clone the official Minecraft Forge or NeoForge repository using Git to create your development environment. Use the command git clone https://github.com/MinecraftForge/MinecraftForge.git to fetch the source files locally. Navigate into the folder and run gradlew setupDecworkspace to generate the necessary project structure files. This process prepares your IDE to recognize Minecraft classes and handle dependency management automatically. You confirm the workspace is ready when the build log shows no errors.
3. Configure Your Mod ID and Metadata
Open the mod.toml file inside your src/main/resources folder to edit your mod configuration details. Set the modid field to a unique lowercase string like myfirstmod and define the version as 1.0.0. Specify the author name and description so the game recognizes your mod correctly during startup. These metadata fields prevent conflicts with other mods and help players identify your work in the menu. You see your mod name appear in the Mods list when launching the game.
4. Create Your First Item Class
Create a new Java file named MyItem.java inside your items package directory. Extend the Item class and set the tab property to CREATIVE tab to make it appear in the creative inventory. Register this item in your registry class using the DeferredRegister with the Items registry type. This structure allows the game to load your custom item alongside vanilla items during initialization. You find the item listed under your mod name in the creative tab inventory.
5. Add Item Models and Textures
Create a JSON file named myfirstmod:my_item in the assets folder to define how the item looks. Link the texture path to a PNG file you placed in the textures/item directory with correct dimensions. Run the Gradle task genSources to ensure your assets are recognized by the development environment. Proper model files prevent the item from appearing as a purple black missing texture in game. You see the item render with your custom texture when you hold it in hand.
6. Register the Item in the Registry
Locate your ModRegistry class and add the item to the DeferredRegister list using a static field. Use a method called register and pass the registry key and the item supplier to link them together. Ensure the registry class is initialized early in your mod main class constructor method. Registration is critical because unregistered items will not load or exist in the game world. You verify registration by checking the console log for your modid during startup.
7. Run the Game in Development Mode
Open your IDE run configuration and select the client option to launch the game with your mod loaded. Set the environment variable to development mode so you can see logs and debug errors easily. Click run to start the game and watch the console output for any startup crashes or warnings. This step confirms that your code compiles and the game loads your mod without issues. You enter the main menu and see your mod listed in the installed mods screen.
8. Test Your Item In-Game
Press the T key to open the chat and type /give yourmodidmy_item to spawn your new item. Check your hotbar or inventory to confirm the item appears with the correct name and icon. Use the item in the world to ensure it functions as expected without crashing the game. Testing validates that your registry and model configurations are correct and the mod is stable. You hold the item and see its unique texture render correctly on your screen.
9. Troubleshoot Common Errors
If the game crashes, check the latest.log file in the logs folder for stack traces or error messages. Look for missing dependencies or incorrect mod IDs that often cause startup failures in development. Update your dependencies in the build.gradle file to match the exact version of Minecraft you target. Resolving these issues early saves time and prevents frustration during your development process. You fix the error and successfully launch the game without crashes or missing textures.