User Tools

Site Tools


Sidebar

← Go back to the homepage

Fabric Tutorials

Setup

These pages will help you setup a productive development environment and semi-automated releases.

Basics

These pages are essential must-reads when modding with Fabric, and modding Minecraft in general, if you are new to modding, it is recommended you read the following.

Items

Blocks and Block Entities

Data Generation

World Generation

Commands

These pages will guide you through Mojang's Brigadier library which allows you to create commands with complex arguments and actions.

Events

These pages will guide you through using the many events included in Fabric API, and how to create your own events for you or other mods to use.

Entities

Fluids

Mixins & ASM

These pages will guide you through the usage of SpongePowered's Mixin library, which is a highly complex topic. We recommend you read these pages thoroughly.

Miscellaneous

Yarn

Contribute to Fabric

tutorial:mixin_registration

Registering Mixins

Introduction

In this tutorial, you will learn how to register your Mixins through the resources/fabric.mod.json.

Inside your resources folder is where your fabric.mod.json should be.

Use this link to view the Fabric Example Mod's resources folder: Fabric Example Mod Resources

Inside your fabric.mod.json is where you define where Fabric should look for your mixins.json.

Register Mixins with Fabric

To register a mixin you have to tell Fabric where to look. To tell Fabric where to look you need to add elements to the mixins array inside fabric.mod.json

  1. {
  2. "mixins": [
  3. "modid.mixins.json"
  4. ]
  5. }

Providing a String "<modid>.mixins.json" inside the mixins array tells Fabric to load the mixins defined inside the file <modid>.mixins.json.

Register Mixins

In the previous section, you learned about registering your <modid>.mixins.json files.

We still have to define which mixins to load and where these mixins are located.

Inside your registered <modid>.mixins.json:

{
  "required": true,
  "minVersion": "0.8",
  "package": "net.fabricmc.example.mixin",
  "compatibilityLevel": "JAVA_17",
  "mixins": [],
  "client": [
    "TitleScreenMixin"
  ],
  "server": [],
  "injectors": {
    "defaultRequire": 1
  }
}

The 4 main fields you should worry about when getting started with mixins are the package field, and the mixins, client, server arrays.

The package field defines which folder (package) to find the Mixins in.

The mixins array defines which classes should be loaded on both the client and server.

The client array defines which classes should be loaded on the client.

The server array defines which classes should be loaded on the server.

Following that logic: net.fabricmc.example.mixin.TitleScreenMixin is the mixin class that will be loaded on the client.

tutorial/mixin_registration.txt · Last modified: 2022/08/17 22:25 (external edit)