User Tools

Site Tools


tutorial:stats

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:stats [2021/02/08 18:51] – increment stats on both server and client jummittutorial:stats [2024/11/18 16:45] (current) – identifier constructor is private, Registries class bemoty
Line 4: Line 4:
 To add a custom statistic, create an identifier which will be used to register and increase the stat: To add a custom statistic, create an identifier which will be used to register and increase the stat:
 <code java> <code java>
-public static final Identifier INTERACT_WITH_COOL_BLOCK = new Identifier("modid", "interact_with_cool_block");+public static final Identifier INTERACT_WITH_COOL_BLOCK = Identifier.of("modid", "interact_with_cool_block");
 </code> </code>
  
Line 11: Line 11:
 Then register the stat using the identifier: Then register the stat using the identifier:
 <code java> <code java>
-Registry.register(Registry.CUSTOM_STAT, "interact_with_cool_block", INTERACT_WITH_COOL_BLOCK);+Registry.register(Registries.CUSTOM_STAT, "interact_with_cool_block", INTERACT_WITH_COOL_BLOCK);
 </code> </code>
  
-Then specify the stat formatter. It determines how the number is shown in the Statistics screen. You can use DEFAULT, DIVIDE_BY_TEN, DISTANCE or TIME.+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.
  
 <code java> <code java>
tutorial/stats.1612810277.txt.gz · Last modified: 2021/02/08 18:51 by jummit