Fabric Loom

repository·dev/1.18·Indexed 43 days ago

https://github.com/fabricmc/fabric-loom

A Gradle plugin that provides a deobfuscated development environment for Minecraft modding. It handles mappings (including Yarn), decompilation via Fernflower and CFR, and automatically generates IDE run configurations for IntelliJ IDEA, Eclipse, and Visual Studio Code. Requires Gradle 7+ and Java 16+.

Tokens
1.1K
Snippets
3
Records
6
Agent score
57%

What's inside Fabric Loom

  1. What is Fabric Loom

    dev/1.18

    Fabric Loom is a Gradle plugin designed to set up a deobfuscated development environment for Minecraft mods. It is the primary tool used in the Fabric toolchain and provides several key features:

    • Mappings Support: Built-in support for tiny mappings (used by Yarn).
    • Decompilation: Utilizes Fernflower and CFR decompilers to generate source code with comments.
    • IDE Integration: Automatically generates run configurations for IntelliJ IDEA, Eclipse, and Visual Studio Code.
    • Compatibility: Designed for modern Minecraft versions (tested from 1.14.4 upwards).

    Requirements:

    • Gradle: Version 7 or newer.
    • Java: Version 16 or higher.
  2. Debug Fabric Loom (for Loom contributors)

    dev/1.18

    If you are contributing to the Loom repository itself, follow these steps using IntelliJ IDEA to run Loom in debug mode:

    1. Import Project: Open build.gradle and import it as a Gradle project.
    2. Build and Publish Locally: Create a Gradle run configuration to execute the following tasks:
      build publishToMavenLocal -x test
      This builds Loom and publishes it to your local Maven repository without running tests.
    3. Configure a Test Project:
      • Clone a template like fabric-example-mod into your working directory.
      • Add mavenLocal() to your repositories. The location depends on how you apply the plugin:
        • If using id 'fabric-loom' in the plugins block: Add to pluginManagement in settings.gradle.
        • If using apply plugin:: Add to the buildscript block in build.gradle.
      • Set the Loom version to 0.6.local (e.g., id 'fabric-loom' version '0.6.local').
    4. Set up Debugging Workflow:
      • Create a new Gradle run configuration for your test project.
      • Set the Gradle project path to your configured test project.
      • Add the 'Build and Publish' configuration created in step 2 to the Before Launch section of this configuration. This ensures Loom is rebuilt whenever you debug.
    5. Run: You can now run the test project in debug mode with working breakpoints.
    build publishToMavenLocal -x test
  3. Sign in and out of Microsoft authentication in Loom

    dev/1.18

    Loom provides Gradle tasks to manage your Microsoft authentication state locally.

    Signing In

    Run the microsoftLogin task once to sign in. Loom stores the encrypted account in <GRADLE_USER_HOME>/caches/fabric-loom/microsoft-auth.json. This stored account is shared across all projects using the same Gradle user home. The runClient task will automatically refresh the account and pass the Minecraft access token to the game.

    Signing Out

    Run the microsoftLogout task to delete the locally stored account and its platform-protected key.

    Note: Logout is local to the current Gradle user home. Because the personal-account flow lacks a supported per-token revocation endpoint, logging out only removes the local credentials and does not revoke the token on Microsoft's side.

    # To sign in
    ./gradlew microsoftLogin
    
    # To sign out
    ./gradlew microsoftLogout
  4. Reconstruct the Minecraft certificate chain

    dev/1.18

    If you need to manually reconstruct the Minecraft certificate chain, you can do so by extracting MOJANGCS.RSA from the vanilla Minecraft JAR and then using OpenSSL to convert it into a PEM format. This is useful for verifying or working with Minecraft's certificate structure.

    openssl pkcs7 -inform DER -in MOJANGCS.RSA -print_certs -out cert.pem
  5. Configure Microsoft authentication for Loom

    dev/1.18

    To enable Microsoft authentication (required for certain Minecraft account flows), you must provide a valid Microsoft Application (client) ID.

    1. Set the net.fabricmc.loom.util.Constants.MICROSOFT_CLIENT_ID placeholder to your Application ID.

    To generate a client ID:

    1. Open Microsoft Entra and navigate to Identity > Applications > App registrations.
    2. Create a new registration that supports personal Microsoft accounts.
    3. Under Authentication > Advanced settings, enable Allow public client flows.
    4. Copy the Application (client) ID from the application's overview page.