User Tools

Site Tools


← Go back to the homepage

Fabric Tutorials


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


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 Player Statistics

Statistics track time spend doing something, distance traveled or jumped, and how often the player interacted with blocks or performed certain actions.

To add a custom statistic, create an identifier which will be used to register and increase the stat:

public static final Identifier INTERACT_WITH_COOL_BLOCK = new Identifier("modid", "interact_with_cool_block");


Then register the stat using the identifier:

Registry.register(Registry.CUSTOM_STAT, "interact_with_cool_block", INTERACT_WITH_COOL_BLOCK);

Then add the stat to the statistic screen, where you can also specify the stat formatter. It determines how the number is shown in the stat list. You can use DEFAULT, DIVIDE_BY_TEN, DISTANCE or TIME.


Using The Statistic

To increment the statistic, for example when a player interacts with a block, you can use PlayerEntity::incrementStat:

public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
	return ActionResult.SUCCESS;

You can also use PlayerEntity.increaseStat(stat, amount) to increase the stat by an arbitrary amount.


To translate the name, add an entry for stat.modid.statid (see lang for how to translate the statistic.):

  "stat.modid.interact_with_cool_block": "Interactions with Cool Block"
tutorial/stats.txt · Last modified: 2021/02/08 22:05 (external edit)