Fabric API logoFabric API
Home/Guide/Development
Development

Getting Started With Fabric API as a Mod Developer

Java code in an IDE on a developer workstation building with Fabric API

For anyone writing mods for the Fabric toolchain, Fabric API is the most important dependency in the project. It replaces large amounts of fragile, repetitive code with well-tested events and utilities, and it ensures your mod behaves predictably alongside hundreds of others. This guide introduces the library from a developer's perspective: how to add it to a project, how its event system works, which modules you are likely to use first, and what changed when Minecraft moved to unobfuscated releases with 26.1.

Why build on the library?

Fabric's core tool for changing game behaviour is Mixin, which injects code into game classes at load time. Mixins are flexible, but each one is a potential point of conflict with other mods, and each must be maintained whenever Mojang changes the targeted code. Fabric API contains a carefully maintained set of Mixins for the most common needs and exposes them through stable interfaces. By using the library, you:

  • write far fewer Mixins of your own;
  • share hooks with other mods instead of competing for the same injection points;
  • benefit from fixes and updates made centrally by the FabricMC team;
  • port to new game versions more easily, because many changes are absorbed by the library.

Setting up a project

The quickest way to begin is the template generator on the Fabric website or the official example mod repository. Both produce a Gradle project preconfigured with Fabric Loom, the Gradle plugin that sets up Minecraft for development.

Modern projects (26.1 and newer)

Minecraft 26.1 was the first release distributed without obfuscation. Mappings are no longer needed, and the build tooling changed accordingly. Projects use the net.fabricmc.fabric-loom plugin, which does not remap the game or mods, and dependencies are declared with standard Gradle configurations:

// gradle.properties
minecraft_version=26.3
fabric_api_version=0.164.0+26.3

// build.gradle
plugins {
    id "net.fabricmc.fabric-loom" version "${loom_version}"
}

dependencies {
    minecraft "com.mojang:minecraft:${project.minecraft_version}"
    implementation "net.fabricmc:fabric-loader:${project.loader_version}"
    implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
}

A Java 25 toolchain is required, and IntelliJ IDEA users need version 2025.3 or later for Mixin support to work correctly. Recommended versions of Loom, the loader and the library for each game release are listed on the Fabric developer site.

Older projects (1.21.11 and earlier)

Projects targeting earlier releases continue to use the remapping Loom plugin, a mappings dependency, and the modImplementation configuration for the library. If you maintain such a project and plan to port it to 26.x, first migrate from Yarn to Mojang's official names, then follow the porting guidance in the Fabric documentation.

Declaring the dependency

Every Fabric mod includes a fabric.mod.json file. List the library in its depends block so the loader can verify it at start-up:

{
  "schemaVersion": 1,
  "id": "examplemod",
  "version": "1.0.0",
  "entrypoints": {
    "main": ["com.example.ExampleMod"],
    "client": ["com.example.ExampleModClient"]
  },
  "depends": {
    "fabricloader": ">=0.18.4",
    "minecraft": "~26.3",
    "fabric-api": "*"
  }
}

Use the fabric-api mod ID. The older fabric ID was deprecated for several years and has now been removed, so any project still referencing it must be updated. If your mod relies on a feature added in a specific build, replace * with a minimum version such as ">=0.160.0".

Understanding events

The event system is at the heart of the library. Each event is a static field holding an Event object to which you register callbacks, usually in your mod's initialiser. When the game reaches the relevant moment, the library invokes every registered callback in turn.

For example, running code at the end of every server tick looks like this:

public class ExampleMod implements ModInitializer {
    @Override
    public void onInitialize() {
        ServerTickEvents.END_SERVER_TICK.register(server -> {
            // runs once per server tick
        });
    }
}

Some events allow a callback to influence the outcome. Interaction events, for instance, let a callback return a result indicating whether the action should continue, be cancelled or be treated as successful. Read each event's documentation to understand how results are combined when several mods register callbacks.

The 26.1 update added several new interaction events for finer control over item and block use, and introduced dimension events, illustrating how the library grows to meet developers' needs.

Modules you will use first

  • Lifecycle events: server start and stop, ticks, world and chunk loading.
  • Command API: register commands with the game's Brigadier command framework through a single callback.
  • Networking: define custom payload types and register handlers on client and server.
  • Item groups: add your items to existing creative tabs or create your own.
  • Resource loader: register reload listeners and ship built-in resource or data packs.
  • Data generation: generate recipes, loot tables, tags, models and translations from code during the build.
  • Transfer API: expose item and fluid storage so pipes and machines from other mods can interact with yours.

Because the library is modular, you can depend on individual modules instead of the whole bundle if you want to keep requirements minimal. Most mods, however, simply depend on the complete library, since players install it anyway.

Data generation in practice

Writing JSON files for every recipe, model and loot table is tedious and error-prone. The data generation module lets you describe them in Java and produce the files automatically with a Gradle task. When you rename an item, the generated files update consistently. For mods with large amounts of content, this saves hours and eliminates a common category of bugs.

Networking basics

Modern versions of the game use typed payloads for custom packets. With the library, you define a record that implements the payload interface, register a codec for it, and register a receiver on the side that handles it. Sending data is then a single method call. This approach keeps networking code organised and type-safe, and it works consistently across client and server.

Testing and debugging

Loom provides run configurations for the client and a dedicated server. Use both: many bugs appear only when client code accidentally runs on a server. Fabric also supports a game test framework for automated tests that run inside a real world, which is valuable for complex mechanics.

When you encounter crashes, the library's enhanced crash reports and the standard log are your first resources. Our guide on fixing common errors covers messages your users may report.

Staying current

The library publishes builds frequently, including for snapshots. Following snapshot builds lets you prepare for upcoming game versions well before release. Watch the Fabric blog for announcements accompanying major updates; they summarise renamed APIs, removed deprecated modules and new features, and often include migration tools such as IntelliJ IDEA migration maps.

The Fabric documentation site, the example mod, the library's source code on GitHub and the community Discord server are all valuable resources when you need help.

Depending on individual modules

The full library is published as a single dependency for convenience, but each module is also available as its own artefact. A small mod that only needs lifecycle events and command registration can depend on just those modules, reducing the surface area it relies on. In practice, players almost always install the complete library anyway, so most developers depend on the full bundle and keep their build scripts simple. Module-level dependencies are most useful for libraries of your own that other developers will embed.

Common beginner mistakes

  • Running client code on the server. Classes that reference rendering or the client game instance must only be loaded from client entry points. Use separate source sets or entry points to keep them apart.
  • Writing Mixins for things the library already covers. Before adding a Mixin, search the library's modules and documentation; an event for your need may already exist.
  • Forgetting the dependency declaration. If fabric.mod.json does not list fabric-api, players who forget to install it will see a confusing crash instead of a clear message.
  • Pinning an exact library version. Requiring one specific build makes your mod incompatible with newer ones. Specify a minimum version instead.
  • Ignoring deprecation warnings. Deprecated APIs are eventually removed, as happened with several modules in 26.1. Migrating early avoids rushed fixes later.

Conclusion

Fabric API gives developers a reliable foundation of events, registries, networking and data tools, allowing them to focus on what makes their mod distinctive rather than rewriting common infrastructure. For projects targeting 26.1 and newer, setup is simpler than ever: use the unobfuscated Loom plugin, declare the library as a normal dependency and reference it in fabric.mod.json with the fabric-api ID. Build on its events, take advantage of data generation, test on both client and server, and keep an eye on each release's notes. Your mod will be easier to maintain and far more compatible with the wider ecosystem.