For anyone searching for this, I managed to get it working in 1.15.2 with this code:
public static final ResourceLocation INTERACT_WITH_SHIP_CONTROLLER = registerCustomStat("interact_with_ship_controller");
private static ResourceLocation registerCustomStat(String name) {
ResourceLocation resourcelocation = new ResourceLocation(MOD_ID, name);
Registry.register(Registry.CUSTOM_STAT, name, resourcelocation);
Stats.CUSTOM.get(resourcelocation, IStatFormatter.DEFAULT);
return resourcelocation;
}
You can then increase the stat:
player.addStat(Registry.INTERACT_WITH_SHIP_CONTROLLER);
Don't forget to localize it so it has a name in the stat list:
"stat.sol.interact_with_ship_controller": "Interactions with Ship Controller"
For fun, you can track your new stat with these commands:
/scoreboard objectives add stat minecraft.custom:minecraft.interact_with_ship_controller
/scoreboard objectives setdisplay sidebar stat