-
Notifications
You must be signed in to change notification settings - Fork 2
Forge
- Forge is a popular Minecraft modding framework that allows players to create and customize their Minecraft experience.
- Developed by a community of modders, Forge provides a robust and flexible platform for creating mods.
- Forge simplifies the modding process by handling many technical aspects of mod development.
- Forge simplifies the modding process by providing a framework that handles many of the technical aspects of mod development.
- It provides an extensive API (Application Programming Interface) that allows modders to interact with Minecraft's code and add new features.
Forge plays a vital role in the deployment as it serves as the communication bridge. The Forge API establishes a network connection between the physical computer and the Minecraft front-end servers. This enables seamless and efficient communication between the different components, ensuring a smooth gaming experience. Forge acts as the intermediary, facilitating the transfer of data and commands, and ensuring synchronization between the Minecraft front-end servers and the databases.
We will navigate the platform togther now! Check out the latest Forge MDK: https://docs.minecraftforge.net/en/1.20.x/
-
- An installation of the Java 17 Development Kit (JDK) and 64-bit Java Virtual Machine (JVM). Forge recommends and officially supports Eclipse Temurin.
- An installation of a Java IDE, ideally IntelliJ.
-
- Choose the desired Minecraft version and click on the "Download Recommended" button or select a specific version if needed.
- Download the Forge installer for your operating system.
- Extract the downloaded MDK into an empty directory. This will be your mod’s directory, which should now contain some gradle files and a
src
subdirectory containing the example mod.
-
- Open your preferred Integrated Development Environment (IDE) such as IntelliJ IDEA or Eclipse.
- Create a new Java project.
- Set up the project's build path to include the Forge MDK libraries. Refer to the IDE's documentation for detailed instructions on setting up the build path.
-
-
In your Forge project, you'll find a build.gradle file. This is the Gradle build script for your mod.
-
Open the
build.gradle
file in a text editor or your IDE. -
Customize the build script to specify your mod's dependencies, version, and other configurations.
-
Add any additional Gradle plugins or tasks as needed for your mod.
// In some build.gradle base.archivesName = 'mymod' group = 'com.example' version = '1.19.4-1.0.0.0'
- Replace all occurrences of examplemod, including mods.toml and the main mod file with the mod id of your mod. This also includes changing the name of the file you build by setting base.archivesName (this is typically set to your mod id).
-
It is an important file that describes your mod(s). It contains information about your mod, like its name, version, and author.
-
It also includes details on how the mod should be loaded into the game and how it appears in the game's 'Mods' menu.
-
The mods.toml file follows a format called TOML (Tom's Obvious Minimal Language). To ensure it works correctly, you need to save the file in a specific location, which is in the META-INF folder within the resource directory, which is usually found at
src/main/resources/META-INF/mods.toml
Here's an example of what a mods.toml file might look like:
// Specifies the mod loader used (Java FML) modLoader="javafml" // Specifies the required loader version (any version 45 or higher) loaderVersion="[45,)" // Specifies the license for the mod (All Rights Reserved) license="All Rights Reserved" // Specifies the URL to the issue tracker for reporting mod issues issueTrackerURL="https://github.com/MinecraftForge/MinecraftForge/issues" // Specifies whether the mod should be shown as a resource pack (false) showAsResourcePack=false // Defines a mod modId="examplemod" // Unique identifier for the mod version="1.0.0.0" // Version of the mod displayName="Example Mod" // Display name of the mod updateJSONURL="https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json" // URL for checking mod updates displayURL="https://minecraftforge.net" //URL for displaying more information about the mod logoFile="logo.png" //File name of the mod's logo credits="I'd like to thank my mother and father." //Credits or acknowledgments for the mod authors="Author" //Author(s) of the mod description="Lets you craft dirt into diamonds. This is a traditional mod that has existed for eons. It is ancient."
- Entrypoints are essentially the starting point for executing the mod. The entrypoint itself is determined by the language loader used in the mods.toml.
- The javafml language loader is provided by Forge for the Java programming language.
- The entrypoint is defined using a public class with the
@Mod
annotation. - The value of
@Mod
must contain one of the mod ids specified within the mods.toml.
@Mod("examplemod") // Must match mods.toml! public class Example { public Example() { // Initialize logic here var modBus = FMLJavaModLoadingContext.get().getModEventBus(); // ... } }
- In your IDE, find the Gradle panel or window. This panel allows you to execute various Gradle tasks.
- Expand the tasks tree and locate the
build
task. This task compiles your mod's source code, resolves dependencies, and creates a JAR file. - Run the
build
task. This will trigger the Gradle build process for your mod. - Wait for the build process to complete. Gradle will display the progress and any errors or warnings encountered during the build, if the build is successful you can ignore the warnings.
Once we can see that the runClient task is in motion we can start playing with our mod!
-
After modifying the code and running it we will be greeted by the Minecraft launcher that will allow us to test out our mod