
Stats from other mods
JPeisach opened this issue ยท 2 comments
Question
Was wondering if there is support (or if you'd like me to try to make) for statistics from other mods, such as MoreStats. They don't show up in the stats menu, but /stats query shows it exists
Hello!
Although I haven't used the 'More Stats' mod before, here's generally how things work;
betterstats
retrieves statistics data using the data present in vanilla Minecraft's registries andStatHandler
s.- For "General stats", a general stat has to be explicitly registered in the proper registry (called
CUSTOM
in the game's source code) in order for it to show up in the "General stats" tab. I personally noticed many modders don't do this properly, and this is precisely what lead to crashes and incompatibilities in the past. As such, I have drawn a "hard line", and made it a requirement that the general stat be properly registered in order for it to show up in the "Generaly stats" tab. This resulted in a bunch of mods not having their general stats show up in the "General stats" tab. So to those mods's devs; Please register your general stats properly, using theCUSTOM
registry. - For custom stat types related to entities and items, that still show up in
/stats
, there currently isn't a feature. Depending on the nature on how the game handles those, I may or may not have unfortunately overlooked that part, and only chose to display vanilla stat types in the tooltips. I will look into this and see if its possible to display modded stat types for entity and item stats. - For stats that do not use the game's registries and APIs then; For obvious reasons, no. If another mod is using a completely different modded stats system of its own, then the only way for it to display its stats on this mod's screen is to utilize this mod's API to create a custom stats tab.
So in other words, modded stats are supposed to show up on this mod's screen, but turns out general stats need to be properly registered to show up, and custom entity and item stats got overlooked by me and don't show up, which I'll look into next.
Now, I will go check out 'More Stats' just to see what it looks like and if anything could be done.
By the way, thanks for the question, and happy holidays to you as well!
Edit:
Just a correction, I made a mistake. The registry for general stats is called CUSTOM_STAT
, not CUSTOM
. It is located at net.minecraft.registry.Registries.CUSTOM_STAT
. I know the name is confusing here because it says "custom stat", but just keep in mind that internally when the game's code says "custom", it means "general".
Edit 2:
I looked into 'More Stats''s source code, and it appears the mod registers its general stats properly, and yet despite that, they still don't show up. This is a bug, and i will look into resolving it. Thank you for reporting it.
Now I remembered, I believe the developer of that mod asked if such an integration is possible, back in issue #24. Although at that time this mod's code was messy and had no API. However now it definitely is possible to work on this. This mod offers an API for creating custom stats tabs and buttons in the top menu bar, and in the meantime, I will look into if its possible to feature modded stat types for entities and items.
Although another failure on my end was to document my APIs. For devs out there, you can use https://cursemaven.com
to add tcdcommons
and betterstats
to your gradle projects, after which my API registry for custom stats tabs is located at
io.github.thecsdev.betterstats.api.client.registry.BSClientRegistries.STATS_TAB
.