StatsHelper
com.jsmacrosce.jsmacros.client.api.helper.StatsHelper
Provides access to the player's client-side statistics counters.
Typed methods query a named registry statistic, while custom-stat methods query the named custom statistic directly. Keyed methods accept names from getStatList(); unknown keys throw IllegalArgumentException. getStatText(String) returns the statistic type's display name, not an individual statistic name. updateStatistics() requests updated statistics from the server.
js
if (World.isWorldLoaded()) {
const stats = Player.getStatistics();
Chat.log(`${stats.getBlockMined("minecraft:stone")} stone mined`);
Chat.log(`${stats.getItemUsed("minecraft:diamond_pickaxe")} pickaxe uses`);
stats.updateStatistics();
}Constructors
new StatsHelper
new StatsHelper(StatsCounter base)#Wraps the supplied statistics counter.
Parameters:
base: raw statistics counter to wrap
Methods
getBlockMined
getCustomFormattedStat
getCustomStat
getEntityKilled
getFormattedStatMap
getFormattedStatValue
Returns the counter for the statistic identified by
statKey, formatted by that statistic's formatter.Parameters:
statKey: one of the keys from getStatList()
Returns: the formatted value of the matching statistic
getItemBroken
getItemCrafted
getItemDropped
getItemPickedUp
getItemUsed
getKilledByEntity
getRawStatMap
getRawStatValue
Returns the unformatted counter for the statistic identified by
statKey.Parameters:
statKey: one of the keys from getStatList()
Returns: the raw value of the matching statistic
getStatList
getStatText
Returns the display name of the statistic type identified by
statKey, rather than a name specific to that statistic.Parameters:
statKey: one of the keys from getStatList()
Returns: the text component naming that statistic's category
toString
updateStatistics
Requests that the server send the current statistics over the active connection.
Returns: self for chaining.