User Tools

Site Tools


← Go back to the homepage

Fabric Tutorials



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.


Blocks and Block Entities

Data Generation

World Generation


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


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.



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.



Contribute to Fabric


Adding a Gamerule

Registering a Gamerule

To create a gamerule, register it using the GameRuleRegistry of the Fabric API:

  1. // Create and register a boolean game rule with the name "shouldPigsFly" which is true by default.
  2. public static final GameRules.Key<GameRules.BooleanRule> SHOULD_PIGS_FLY =
  3. GameRuleRegistry.register("shouldPigsFly", Category.MOBS, GameRuleFactory.createBooleanRule(true));

Using the gamerule

To get access to the value of a game rule you need to get the server world:

  1. world.getGameRules().getBoolean(SHOULD_PIGS_FLY)


The registered gamerule now shows up untranslated in the game rule list, which can be opened in the world creation screen. To translate the name, add a gamerule.gameruleName entry (see lang for more info):

  "gamerule.shouldPigsFly": "Pigs should fly"
tutorial/gamerule.txt · Last modified: 2021/12/24 22:00 (external edit)