Claude Skill

minecraft-multiloader

Build and maintain Architectury-based Minecraft 26.x or 1.21.x mods that share one codebase across NeoForge and Fabric. Use only when both loaders are required; use minecraft-modding for a single-loader project.

LLM Mart · 0 points · 10 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download Jahrome907-minecraft-agent-skills-.agents_skills_minecraft-multiloader-dd57c5a.zip · 8 KB
Part of jahrome907/minecraft-agent-skills — 52 skills

Install

skills CLI npx skills add https://github.com/Jahrome907/minecraft-agent-skills/tree/main/.agents/skills/minecraft-multiloader
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install jahrome907-minecraft-agent-skills@llmmart
Git git clone https://github.com/Jahrome907/minecraft-agent-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole jahrome907/minecraft-agent-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Minecraft Multiloader Skill (Architectury)

What Is Architectury?

Architectury is a framework that lets you write one mod codebase that compiles to both NeoForge and Fabric JARs. The common subproject has a shared API; platform subprojects implement platform-specific behavior behind the @ExpectPlatform abstraction.

Routing Boundaries

  • Use when: one shared codebase must build and ship both NeoForge and Fabric artifacts.
  • Do not use when: the project is single-loader only (minecraft-modding for NeoForge/Fabric, not both).
  • Do not use when: the task is Paper/Bukkit plugin development (minecraft-plugin-dev).
Component Purpose
architectury-loom Gradle plugin — extends Fabric Loom for multiloader support
architectury-api Runtime library — abstractions over both platforms
@ExpectPlatform Annotation marking methods with platform-specific implementations
common/ Shared code (no loader-specific APIs)
fabric/ Fabric-specific code + entrypoint
neoforge/ NeoForge-specific code + entrypoint

Versions (Minecraft 1.21.11)

# gradle.properties property names used by this skill's static helper.
# Get every tool version from the exact generated or known-working project.
mod_version=1.0.0
minecraft_version=1.21.11
enabled_platforms=fabric,neoforge

architectury_version=<project pin>
fabric_loader_version=<project pin>
fabric_api_version=<project pin ending in +1.21.11>
neoforge_version=<project pin in the 21.11.x family>
loom_version=<project pin>

Pin architectury_version, the Architectury plugin version, and loom_version from the same generated or known-working project line. This skill deliberately does not publish a copyable dependency matrix: its static helper cannot resolve whether a particular set of versions is compatible.

For Minecraft 26.2 / Java 25, use the official Architectury Template Generator only when its version selector offers the exact target. Generate a Multiplatform project with Fabric and NeoForge, then preserve the generated Gradle layout and pins as one set. If the generator does not offer the target, begin with an already working project on that exact line and inspect its resolved build; do not relabel a 1.21.11 template as 26.2. The published template downloads are not a substitute for an exact-current scaffold.

Do not mechanically change only minecraft_version in the retained example: 26.2 is unobfuscated and its Loom/remapping setup differs from 1.21.11.

Bundled References And Helpers

  • Version alignment reference: references/architectury-reference.md
  • Sanity checker: ./scripts/check-version-sanity.sh --root <project>

Run the sanity checker after editing gradle.properties. It is a static syntax-and-version-family preflight: it catches missing keys, snapshot pins, missing fabric / neoforge platforms, and obvious version-family drift. It does not resolve dependencies, prove loader compatibility, or replace the project's Fabric and NeoForge build and smoke tests.


Root Project Layout

my-mod/
├── build.gradle           ← root build (shared config)
├── settings.gradle
├── gradle.properties
├── common/
│   ├── build.gradle
│   └── src/main/java/com/example/mymod/
│       ├── MyMod.java               ← shared init
│       ├── registry/
│       │   └── ModItems.java        ← shared registry declarations
│       └── platform/
│           └── PlatformHelper.java  ← @ExpectPlatform methods
├── fabric/
│   ├── build.gradle
│   └── src/main/
│       ├── java/com/example/mymod/fabric/
│       │   ├── MyModFabric.java          ← Fabric entrypoint
│       ├── java/com/example/mymod/platform/
│       │   └── PlatformHelperImpl.java   ← Fabric @ExpectPlatform implementation
│       └── resources/
│           ├── fabric.mod.json
│           └── assets/...
└── neoforge/
    ├── build.gradle
    └── src/main/
        ├── java/com/example/mymod/neoforge/
        │   ├── MyModNeoForge.java        ← NeoForge @Mod entry
        ├── java/com/example/mymod/platform/
        │   └── PlatformHelperImpl.java   ← NeoForge @ExpectPlatform implementation
        └── resources/
            ├── META-INF/neoforge.mods.toml
            └── assets/...

Legacy Build Template

The old fixed Gradle scripts were a 1.21.11 snapshot and are intentionally not presented as a current scaffold. For either supported version, read references/legacy-1.21.11-template.md or references/architectury-reference.md before changing generated build files. They preserve version anchors and source-set boundaries without encouraging a partial build script to be copied into a different Minecraft line.


Shared Common Code

common/.../MyMod.java

package com.example.mymod;

import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;

public class MyMod {
    public static final String MOD_ID = "mymod";

    // Architectury's DeferredRegister — works on both platforms
    public static final DeferredRegister<Item> ITEMS =
        DeferredRegister.create(MOD_ID, Registries.ITEM);

    public static final RegistrySupplier<Item> MY_ITEM =
        ITEMS.register("my_item", () -> new Item(new Item.Properties().setId(
            ResourceKey.create(Registries.ITEM,
                Identifier.fromNamespaceAndPath(MOD_ID, "my_item"))
        )));

    public static void init() {
        ITEMS.register(); // registers with both platforms
    }
}

@ExpectPlatform — platform-specific methods

Define the contract in common/:

package com.example.mymod.platform;

import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.level.material.Fluid;

public class PlatformHelper {

    @ExpectPlatform
    public static boolean isModLoaded(String modId) {
        // This body is replaced at compile time by the platform implementation
        throw new AssertionError("ExpectPlatform implementation not found");
    }

    @ExpectPlatform
    public static boolean isClient() {
        throw new AssertionError();
    }
}

Keep each platform implementation in the same Java package as the common @ExpectPlatform class. Only the source set changes between common/, fabric/, and neoforge/.

Implement in fabric/.../platform/PlatformHelperImpl.java:

package com.example.mymod.platform;

import net.fabricmc.loader.api.FabricLoader;

// Class name must match: <common class name>Impl
public class PlatformHelperImpl {

    public static boolean isModLoaded(String modId) {
        return FabricLoader.getInstance().isModLoaded(modId);
    }

    public static boolean isClient() {
        return FabricLoader.getInstance().getEnvironmentType() ==
            net.fabricmc.api.EnvType.CLIENT;
    }
}

Implement in neoforge/.../platform/PlatformHelperImpl.java:

package com.example.mymod.platform;

import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLEnvironment;

public class PlatformHelperImpl {

    public static boolean isModLoaded(String modId) {
        return ModList.get().isLoaded(modId);
    }

    public static boolean isClient() {
        return FMLEnvironment.dist.isClient();
    }
}

Fabric Entrypoint

fabric/.../MyModFabric.java

package com.example.mymod.fabric;

import com.example.mymod.MyMod;
import net.fabricmc.api.ModInitializer;

public class MyModFabric implements ModInitializer {
    @Override
    public void onInitialize() {
        MyMod.init();
    }
}

fabric/.../resources/fabric.mod.json

This retained-1.21.11 metadata example follows the minimum dependencies in the upstream Architectury 1.21.11 branch. Keep the generated project's exact ranges when they are stricter.

{
  "schemaVersion": 1,
  "id": "mymod",
  "version": "${version}",
  "name": "My Mod",
  "description": "A multiloader example mod",
  "license": "MIT",
  "environment": "*",
  "entrypoints": {
    "main": ["com.example.mymod.fabric.MyModFabric"]
  },
  "depends": {
    "fabricloader": ">=0.18.2",
    "fabric-api": ">=0.139.4+1.21.11",
    "architectury": ">=19.0",
    "minecraft": "~1.21.11"
  }
}

NeoForge Entrypoint

neoforge/.../MyModNeoForge.java

package com.example.mymod.neoforge;

import com.example.mymod.MyMod;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;

@Mod(MyMod.MOD_ID)
public class MyModNeoForge {
    public MyModNeoForge(IEventBus modEventBus) {
        MyMod.init();
    }
}

neoforge/.../resources/META-INF/neoforge.mods.toml

modLoader = "javafml"
loaderVersion = "[1,)"
license = "MIT"

[[mods]]
modId = "mymod"
version = "${file.jarVersion}"
displayName = "My Mod"
description = "A multiloader example mod"

[[dependencies.mymod]]
modId = "neoforge"
type = "required"
versionRange = "[21.11,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.mymod]]
modId = "minecraft"
type = "required"
versionRange = "[1.21.11,1.22)"
ordering = "NONE"
side = "BOTH"

Build Commands

# Build both JARs simultaneously
./gradlew build

# Inspect the project's actual outputs. Generated templates choose their own
# archive base name and version convention:
find fabric/build/libs neoforge/build/libs -maxdepth 1 -type f -name '*.jar' \
  ! -name '*-sources.jar' ! -name '*-dev.jar' ! -name '*-javadoc.jar'

# Run in dev environment
./gradlew :fabric:runClient
./gradlew :neoforge:runClient
./gradlew :neoforge:runServer

# Datagen (if applicable)
./gradlew :neoforge:runData

Common Pitfalls

Pitfall Solution
Using net.neoforged.* / net.fabricmc.* in common/ Only use vanilla MC and Architectury APIs in common
Direct field access on DeferredRegister (NeoForge style) in common Use Architectury's DeferredRegister
Constructing a 26.2 item without a registry key Create its ResourceKey<Item> and call Item.Properties#setId before new Item
Forgetting @ExpectPlatform throws AssertionError at runtime Both fabric/ and neoforge/ must have matching same-package *Impl classes
Assets duplicated in fabric/ and neoforge/ Keep assets in common/src/main/resources/assets/
A common Mixin imports a loader API or targets one loader's side Put it in that platform subproject; loader-neutral Mixins may be common when both generated platform configurations include them
Accessing world/registry on mod init thread Use mod bus events for setup; never access world on init

References

Files (minecraft-agent-skills)
  • references
    • architectury-reference.md 2.7 KB
      # Architectury Version And Layout Reference
      
      Use this file together with `SKILL.md` when you need the quick alignment rules.
      
      ## Shared Code Boundaries
      
      - `common/` may use vanilla Minecraft classes and Architectury APIs only
      - `fabric/` owns Fabric loader APIs, Fabric entrypoints, and Fabric-only hooks
      - `neoforge/` owns NeoForge loader APIs, `@Mod` entrypoints, NeoForge events, and datagen runs
      - A loader-neutral Mixin may be packaged from `common/` when both generated
        platform resource/configuration paths include it. Keep Mixins with loader API
        imports, platform-only targets, or platform-only side rules in that platform.
      
      ## Version Alignment Rules
      
      ### Minecraft 1.21.x
      
      - Keep `minecraft_version` on one explicit 1.21.x patch line across the whole repo
      - Keep `neoforge_version` on the matching `21.<patch>.x` family for that same patch
      - Keep Fabric API on the exact Minecraft patch suffix you target, for example `+1.21.11` for `minecraft_version=1.21.11`
      
      ### Minecraft 26.2
      
      - Use the official [Architectury Template Generator](https://generate.architectury.dev/)
        only when it offers the exact 26.2 target with Fabric and NeoForge. Preserve
        its Minecraft, Java 25, Loom, Fabric API, NeoForge, and Architectury pins as
        one set.
      - If the generator lacks that target, use a known-working project on the exact
        line as the starting point. Inspect its Gradle files and resolve its build
        before changing pins; do not manufacture a current matrix from a 1.21.11
        example or an older template download.
      
      For both versions, keep `enabled_platforms=fabric,neoforge`, avoid snapshot-only
      pins unless intentionally testing a prerelease, and use the split Architectury
      artifacts (`architectury`, `architectury-fabric`, and `architectury-neoforge`).
      
      ## Sanity Check Workflow
      
      ```bash
      ./scripts/check-version-sanity.sh --root .
      ./scripts/check-version-sanity.sh --root . --strict
      ```
      
      The checker performs a static preflight and validates:
      
      - required keys exist in `gradle.properties`
      - `enabled_platforms` contains both `fabric` and `neoforge`
      - snapshot versions are flagged
      - NeoForge version family matches the Minecraft patch line for Minecraft 1.21.x
      
      It does not download or resolve dependencies, compile the project, or establish
      that a specific Architectury, Fabric API, NeoForge, and Loom combination is
      compatible. Use the project build and both loader smoke tests for that evidence.
      
      ## Release Checklist
      
      - build both jars with `./gradlew build`
      - smoke test both `:fabric:runClient` and `:neoforge:runClient`
      - inspect the actual Fabric and NeoForge JAR names under each `build/libs/`
        directory; archive-name conventions come from the selected project template
      - keep one changelog entry for shared logic and call out loader-specific fixes only when behavior differs
      
    • legacy-1.21.11-template.md 2.6 KB
      # Architectury 1.21.11 Template Notes
      
      Use this reference only for a project that uses
      Minecraft 1.21.11 and Java 21. It is not a 26.x migration recipe.
      
      ## Source of Truth
      
      Use the official [Architectury Template Generator](https://generate.architectury.dev/)
      when it offers Minecraft 1.21.11 with a Multiplatform project that includes
      Fabric and NeoForge. Keep its generated Gradle layout, plugin versions, and
      loader wiring together. If that target is unavailable, start from a known-working
      1.21.11 project and verify its resolved build before changing pins. Do not treat
      an older template download as an unverified current scaffold. The root
      `gradle.properties` must identify both platforms:
      
      ```properties
      # These are property names and family constraints, not a released pin matrix.
      # Copy values only from the generated or known-working 1.21.11 project.
      mod_version=1.0.0
      minecraft_version=1.21.11
      enabled_platforms=fabric,neoforge
      
      architectury_version=<project pin>
      fabric_loader_version=<project pin>
      fabric_api_version=<project pin ending in +1.21.11>
      neoforge_version=<project pin in the 21.11.x family>
      loom_version=<project pin>
      ```
      
      The generated layout should keep `common/`, `fabric/`, and `neoforge/` as
      separate source sets. Put shared resources in `common/src/main/resources`; keep
      each loader's metadata in its platform project.
      
      ## Shared And Loader-Specific Code
      
      The common source set may use vanilla and Architectury APIs. `@ExpectPlatform`
      is appropriate for a small loader boundary, with same-package `*Impl` classes in
      both platform source sets. Keep loader APIs and entrypoints in the matching
      platform source set.
      
      A loader-neutral Mixin may live in common only when its configuration and
      resources are included for both Fabric and NeoForge by the generated template.
      Keep a Mixin in its platform source set when it imports a loader API, uses a
      platform-only target or side, or needs platform-specific configuration.
      
      ## Metadata Anchors
      
      The Fabric metadata must use the template's loader, Fabric API, and Minecraft
      version ranges. The NeoForge metadata belongs at
      `neoforge/src/main/resources/META-INF/neoforge.mods.toml` and its Minecraft and
      NeoForge dependency ranges must match Minecraft 1.21.11. Do not copy these
      1.21.11 values into a 26.x project.
      
      ## Verification
      
      Run `./scripts/check-version-sanity.sh --root <project>` after changing version
      properties, then build both artifacts. The helper checks static properties only;
      it does not prove dependency compatibility. For exact project code, consult the
      generated or known-working project rather than trying to repair a copied,
      partial Gradle example.
      
  • scripts
    • check-version-sanity.sh 4.5 KB
      #!/usr/bin/env bash
      set -euo pipefail
      
      PASS='[PASS]'
      WARN='[WARN]'
      FAIL='[FAIL]'
      
      ROOT='.'
      STRICT=0
      
      while [[ $# -gt 0 ]]; do
        case "$1" in
          --root)
            ROOT="${2:-}"
            shift 2
            ;;
          --strict)
            STRICT=1
            shift
            ;;
          --help|-h)
            cat <<'USAGE'
      Usage: check-version-sanity.sh [--root <path>] [--strict]
      
      Performs static Architectury multiloader version-alignment preflight:
      - gradle.properties exists with required keys
      - gradle.properties declares the local mod_version convention used by this helper
      - enabled_platforms includes fabric and neoforge
      - no snapshot-only toolchain pins unless you accept warnings
      - NeoForge version family matches the Minecraft release line
      - Fabric API suffix matches the Minecraft patch line
      
      This helper does not resolve dependencies, compile the project, or prove a
      specific Architectury / Fabric API / NeoForge / Loom combination is compatible.
      USAGE
            exit 0
            ;;
          *)
            echo "$FAIL unknown arg: $1" >&2
            exit 1
            ;;
        esac
      done
      
      if [[ ! -d "$ROOT" ]]; then
        echo "$FAIL root path does not exist: $ROOT" >&2
        exit 1
      fi
      
      PROPS="$ROOT/gradle.properties"
      if [[ ! -f "$PROPS" ]]; then
        echo "$FAIL missing gradle.properties" >&2
        exit 1
      fi
      
      FAILURES=0
      WARNINGS=0
      
      pass() { echo "$PASS $*"; }
      warn() { echo "$WARN $*"; WARNINGS=$((WARNINGS + 1)); }
      fail() { echo "$FAIL $*"; FAILURES=$((FAILURES + 1)); }
      
      read_prop() {
        local key="$1"
        local value
        value="$(awk -v key="$key" '
          /^[[:space:]]*[#!]/ { next }
          {
            line = $0
            sub(/\r$/, "", line)
            sub(/^[[:space:]]+/, "", line)
            pattern = "^" key "[[:space:]]*([:=]|[[:space:]])"
            if (line ~ pattern) {
              sub("^" key "[[:space:]]*([:=][[:space:]]*|[[:space:]]+)", "", line)
              sub(/[[:space:]]+$/, "", line)
              print line
              exit
            }
          }
        ' "$PROPS")"
        value="${value//$'\r'/}"
        printf '%s' "$value"
      }
      
      MINECRAFT_VERSION="$(read_prop minecraft_version)"
      ENABLED_PLATFORMS="$(read_prop enabled_platforms)"
      ARCHITECTURY_VERSION="$(read_prop architectury_version)"
      FABRIC_LOADER_VERSION="$(read_prop fabric_loader_version)"
      FABRIC_API_VERSION="$(read_prop fabric_api_version)"
      NEOFORGE_VERSION="$(read_prop neoforge_version)"
      LOOM_VERSION="$(read_prop loom_version)"
      
      for key in mod_version minecraft_version enabled_platforms architectury_version fabric_loader_version fabric_api_version neoforge_version loom_version; do
        value="$(read_prop "$key")"
        if [[ -n "$value" ]]; then
          pass "gradle.properties has $key"
        else
          fail "gradle.properties missing key: $key"
        fi
      done
      
      NORMALIZED_PLATFORMS="${ENABLED_PLATFORMS//[[:space:]]/}"
      if [[ ",${NORMALIZED_PLATFORMS}," == *,fabric,* && ",${NORMALIZED_PLATFORMS}," == *,neoforge,* ]]; then
        pass "enabled_platforms includes fabric and neoforge"
      else
        fail "enabled_platforms must include fabric and neoforge"
      fi
      
      for version_name in ARCHITECTURY_VERSION FABRIC_LOADER_VERSION NEOFORGE_VERSION LOOM_VERSION; do
        value="${!version_name:-}"
        if [[ "$value" == *SNAPSHOT* ]]; then
          warn "snapshot version detected: ${version_name,,}=$value"
        fi
      done
      
      if [[ "$MINECRAFT_VERSION" =~ ^1\.21(\.([0-9]+))?$ ]]; then
        patch="${BASH_REMATCH[2]:-1}"
        expected_prefix="21.${patch}."
        if [[ "$NEOFORGE_VERSION" == "$expected_prefix"* ]]; then
          pass "neoforge_version matches Minecraft patch line ($expected_prefix*)"
        else
          fail "neoforge_version should start with $expected_prefix for minecraft_version=$MINECRAFT_VERSION"
        fi
      elif [[ "$MINECRAFT_VERSION" =~ ^(26|[3-9][0-9])\.([0-9]+)(\.[0-9]+)?$ ]]; then
        expected_prefix="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}."
        if [[ "$NEOFORGE_VERSION" == "$expected_prefix"* ]]; then
          pass "neoforge_version matches Minecraft release line ($expected_prefix*)"
        else
          fail "neoforge_version should start with $expected_prefix for minecraft_version=$MINECRAFT_VERSION"
        fi
      else
        warn "minecraft_version is outside the documented 26.x / 1.21.x scope: $MINECRAFT_VERSION"
      fi
      
      if [[ -n "$FABRIC_API_VERSION" && "$FABRIC_API_VERSION" == *+"$MINECRAFT_VERSION" ]]; then
        pass "fabric_api_version suffix matches minecraft_version (+$MINECRAFT_VERSION)"
      else
        warn "fabric_api_version suffix should match minecraft_version (+$MINECRAFT_VERSION)"
      fi
      
      echo ""
      if [[ "$FAILURES" -gt 0 ]]; then
        echo "$FAIL multiloader version sanity failed with $FAILURES error(s) and $WARNINGS warning(s)"
        exit 1
      fi
      
      if [[ "$STRICT" -eq 1 && "$WARNINGS" -gt 0 ]]; then
        echo "$FAIL multiloader version sanity strict mode failed on $WARNINGS warning(s)"
        exit 1
      fi
      
      echo "$PASS multiloader version sanity passed with $WARNINGS warning(s)"
      
  • SKILL.md 11.9 KB
    ---
    name: minecraft-multiloader
    description: "Build and maintain Architectury-based Minecraft 26.x or 1.21.x mods that share one codebase across NeoForge and Fabric. Use only when both loaders are required; use minecraft-modding for a single-loader project."
    ---
    
    # Minecraft Multiloader Skill (Architectury)
    
    ## What Is Architectury?
    
    [Architectury](https://github.com/architectury/architectury-api) is a framework that
    lets you write one mod codebase that compiles to both **NeoForge** and **Fabric** JARs.
    The common subproject has a shared API; platform subprojects implement
    platform-specific behavior behind the `@ExpectPlatform` abstraction.
    
    ### Routing Boundaries
    - `Use when`: one shared codebase must build and ship both NeoForge and Fabric artifacts.
    - `Do not use when`: the project is single-loader only (`minecraft-modding` for NeoForge/Fabric, not both).
    - `Do not use when`: the task is Paper/Bukkit plugin development (`minecraft-plugin-dev`).
    
    | Component | Purpose |
    |-----------|---------|
    | `architectury-loom` | Gradle plugin — extends Fabric Loom for multiloader support |
    | `architectury-api` | Runtime library — abstractions over both platforms |
    | `@ExpectPlatform` | Annotation marking methods with platform-specific implementations |
    | `common/` | Shared code (no loader-specific APIs) |
    | `fabric/` | Fabric-specific code + entrypoint |
    | `neoforge/` | NeoForge-specific code + entrypoint |
    
    ---
    
    ## Versions (Minecraft 1.21.11)
    
    ```properties
    # gradle.properties property names used by this skill's static helper.
    # Get every tool version from the exact generated or known-working project.
    mod_version=1.0.0
    minecraft_version=1.21.11
    enabled_platforms=fabric,neoforge
    
    architectury_version=<project pin>
    fabric_loader_version=<project pin>
    fabric_api_version=<project pin ending in +1.21.11>
    neoforge_version=<project pin in the 21.11.x family>
    loom_version=<project pin>
    ```
    
    Pin `architectury_version`, the Architectury plugin version, and `loom_version`
    from the same generated or known-working project line. This skill deliberately
    does not publish a copyable dependency matrix: its static helper cannot resolve
    whether a particular set of versions is compatible.
    
    For Minecraft 26.2 / Java 25, use the official
    [Architectury Template Generator](https://generate.architectury.dev/) only when
    its version selector offers the exact target. Generate a **Multiplatform**
    project with Fabric and NeoForge, then preserve the generated Gradle layout and
    pins as one set. If the generator does not offer the target, begin with an
    already working project on that exact line and inspect its resolved build; do
    not relabel a 1.21.11 template as 26.2. The published template downloads are
    not a substitute for an exact-current scaffold.
    
    Do not mechanically change only `minecraft_version` in the retained example:
    26.2 is unobfuscated and its Loom/remapping setup differs from 1.21.11.
    
    ## Bundled References And Helpers
    
    - Version alignment reference: `references/architectury-reference.md`
    - Sanity checker: `./scripts/check-version-sanity.sh --root <project>`
    
    Run the sanity checker after editing `gradle.properties`. It is a static
    syntax-and-version-family preflight: it catches missing keys, snapshot pins,
    missing `fabric` / `neoforge` platforms, and obvious version-family drift. It
    does not resolve dependencies, prove loader compatibility, or replace the
    project's Fabric and NeoForge build and smoke tests.
    
    ---
    
    ## Root Project Layout
    
    ```
    my-mod/
    ├── build.gradle           ← root build (shared config)
    ├── settings.gradle
    ├── gradle.properties
    ├── common/
    │   ├── build.gradle
    │   └── src/main/java/com/example/mymod/
    │       ├── MyMod.java               ← shared init
    │       ├── registry/
    │       │   └── ModItems.java        ← shared registry declarations
    │       └── platform/
    │           └── PlatformHelper.java  ← @ExpectPlatform methods
    ├── fabric/
    │   ├── build.gradle
    │   └── src/main/
    │       ├── java/com/example/mymod/fabric/
    │       │   ├── MyModFabric.java          ← Fabric entrypoint
    │       ├── java/com/example/mymod/platform/
    │       │   └── PlatformHelperImpl.java   ← Fabric @ExpectPlatform implementation
    │       └── resources/
    │           ├── fabric.mod.json
    │           └── assets/...
    └── neoforge/
        ├── build.gradle
        └── src/main/
            ├── java/com/example/mymod/neoforge/
            │   ├── MyModNeoForge.java        ← NeoForge @Mod entry
            ├── java/com/example/mymod/platform/
            │   └── PlatformHelperImpl.java   ← NeoForge @ExpectPlatform implementation
            └── resources/
                ├── META-INF/neoforge.mods.toml
                └── assets/...
    ```
    
    ---
    
    ## Legacy Build Template
    
    The old fixed Gradle scripts were a 1.21.11 snapshot and are intentionally not
    presented as a current scaffold. For either supported version, read
    [`references/legacy-1.21.11-template.md`](references/legacy-1.21.11-template.md)
    or [`references/architectury-reference.md`](references/architectury-reference.md)
    before changing generated build files. They preserve version anchors and
    source-set boundaries without encouraging a partial build script to be copied
    into a different Minecraft line.
    
    ---
    
    ## Shared Common Code
    
    ### `common/.../MyMod.java`
    ```java
    package com.example.mymod;
    
    import dev.architectury.registry.registries.DeferredRegister;
    import dev.architectury.registry.registries.RegistrySupplier;
    import net.minecraft.core.registries.Registries;
    import net.minecraft.resources.Identifier;
    import net.minecraft.resources.ResourceKey;
    import net.minecraft.world.item.Item;
    
    public class MyMod {
        public static final String MOD_ID = "mymod";
    
        // Architectury's DeferredRegister — works on both platforms
        public static final DeferredRegister<Item> ITEMS =
            DeferredRegister.create(MOD_ID, Registries.ITEM);
    
        public static final RegistrySupplier<Item> MY_ITEM =
            ITEMS.register("my_item", () -> new Item(new Item.Properties().setId(
                ResourceKey.create(Registries.ITEM,
                    Identifier.fromNamespaceAndPath(MOD_ID, "my_item"))
            )));
    
        public static void init() {
            ITEMS.register(); // registers with both platforms
        }
    }
    ```
    
    ### `@ExpectPlatform` — platform-specific methods
    
    Define the contract in `common/`:
    ```java
    package com.example.mymod.platform;
    
    import dev.architectury.injectables.annotations.ExpectPlatform;
    import net.minecraft.world.level.material.Fluid;
    
    public class PlatformHelper {
    
        @ExpectPlatform
        public static boolean isModLoaded(String modId) {
            // This body is replaced at compile time by the platform implementation
            throw new AssertionError("ExpectPlatform implementation not found");
        }
    
        @ExpectPlatform
        public static boolean isClient() {
            throw new AssertionError();
        }
    }
    ```
    
    Keep each platform implementation in the same Java package as the common
    `@ExpectPlatform` class. Only the source set changes between `common/`,
    `fabric/`, and `neoforge/`.
    
    Implement in `fabric/.../platform/PlatformHelperImpl.java`:
    ```java
    package com.example.mymod.platform;
    
    import net.fabricmc.loader.api.FabricLoader;
    
    // Class name must match: <common class name>Impl
    public class PlatformHelperImpl {
    
        public static boolean isModLoaded(String modId) {
            return FabricLoader.getInstance().isModLoaded(modId);
        }
    
        public static boolean isClient() {
            return FabricLoader.getInstance().getEnvironmentType() ==
                net.fabricmc.api.EnvType.CLIENT;
        }
    }
    ```
    
    Implement in `neoforge/.../platform/PlatformHelperImpl.java`:
    ```java
    package com.example.mymod.platform;
    
    import net.neoforged.fml.ModList;
    import net.neoforged.fml.loading.FMLEnvironment;
    
    public class PlatformHelperImpl {
    
        public static boolean isModLoaded(String modId) {
            return ModList.get().isLoaded(modId);
        }
    
        public static boolean isClient() {
            return FMLEnvironment.dist.isClient();
        }
    }
    ```
    
    ---
    
    ## Fabric Entrypoint
    
    ### `fabric/.../MyModFabric.java`
    ```java
    package com.example.mymod.fabric;
    
    import com.example.mymod.MyMod;
    import net.fabricmc.api.ModInitializer;
    
    public class MyModFabric implements ModInitializer {
        @Override
        public void onInitialize() {
            MyMod.init();
        }
    }
    ```
    
    ### `fabric/.../resources/fabric.mod.json`
    This retained-1.21.11 metadata example follows the minimum dependencies in the
    [upstream Architectury 1.21.11 branch](https://github.com/architectury/architectury-api/tree/1.21.11).
    Keep the generated project's exact ranges when they are stricter.
    
    ```json
    {
      "schemaVersion": 1,
      "id": "mymod",
      "version": "${version}",
      "name": "My Mod",
      "description": "A multiloader example mod",
      "license": "MIT",
      "environment": "*",
      "entrypoints": {
        "main": ["com.example.mymod.fabric.MyModFabric"]
      },
      "depends": {
        "fabricloader": ">=0.18.2",
        "fabric-api": ">=0.139.4+1.21.11",
        "architectury": ">=19.0",
        "minecraft": "~1.21.11"
      }
    }
    ```
    
    ---
    
    ## NeoForge Entrypoint
    
    ### `neoforge/.../MyModNeoForge.java`
    ```java
    package com.example.mymod.neoforge;
    
    import com.example.mymod.MyMod;
    import net.neoforged.bus.api.IEventBus;
    import net.neoforged.fml.common.Mod;
    
    @Mod(MyMod.MOD_ID)
    public class MyModNeoForge {
        public MyModNeoForge(IEventBus modEventBus) {
            MyMod.init();
        }
    }
    ```
    
    ### `neoforge/.../resources/META-INF/neoforge.mods.toml`
    ```toml
    modLoader = "javafml"
    loaderVersion = "[1,)"
    license = "MIT"
    
    [[mods]]
    modId = "mymod"
    version = "${file.jarVersion}"
    displayName = "My Mod"
    description = "A multiloader example mod"
    
    [[dependencies.mymod]]
    modId = "neoforge"
    type = "required"
    versionRange = "[21.11,)"
    ordering = "NONE"
    side = "BOTH"
    
    [[dependencies.mymod]]
    modId = "minecraft"
    type = "required"
    versionRange = "[1.21.11,1.22)"
    ordering = "NONE"
    side = "BOTH"
    ```
    
    ---
    
    ## Build Commands
    
    ```bash
    # Build both JARs simultaneously
    ./gradlew build
    
    # Inspect the project's actual outputs. Generated templates choose their own
    # archive base name and version convention:
    find fabric/build/libs neoforge/build/libs -maxdepth 1 -type f -name '*.jar' \
      ! -name '*-sources.jar' ! -name '*-dev.jar' ! -name '*-javadoc.jar'
    
    # Run in dev environment
    ./gradlew :fabric:runClient
    ./gradlew :neoforge:runClient
    ./gradlew :neoforge:runServer
    
    # Datagen (if applicable)
    ./gradlew :neoforge:runData
    ```
    
    ---
    
    ## Common Pitfalls
    
    | Pitfall | Solution |
    |---------|----------|
    | Using `net.neoforged.*` / `net.fabricmc.*` in `common/` | Only use vanilla MC and Architectury APIs in common |
    | Direct field access on `DeferredRegister` (NeoForge style) in common | Use Architectury's `DeferredRegister` |
    | Constructing a 26.2 item without a registry key | Create its `ResourceKey<Item>` and call `Item.Properties#setId` before `new Item` |
    | Forgetting `@ExpectPlatform` throws `AssertionError` at runtime | Both `fabric/` and `neoforge/` must have matching same-package `*Impl` classes |
    | Assets duplicated in fabric/ and neoforge/ | Keep assets in `common/src/main/resources/assets/` |
    | A common Mixin imports a loader API or targets one loader's side | Put it in that platform subproject; loader-neutral Mixins may be common when both generated platform configurations include them |
    | Accessing world/registry on mod init thread | Use `mod bus` events for setup; never access world on init |
    
    ---
    
    ## References
    
    - Architectury API GitHub: https://github.com/architectury/architectury-api
    - Architectury API 26.2 source branch: https://github.com/architectury/architectury-api/tree/26.2
    - Architectury API 1.21.11 source branch: https://github.com/architectury/architectury-api/tree/1.21.11
    - Architectury Loom: https://github.com/architectury/architectury-loom
    - Architectury templates: https://github.com/architectury/architectury-templates
    - Architectury Template Generator: https://generate.architectury.dev/
    - Architectury docs: https://docs.architectury.dev/
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related