Interface IStatsProvider

All Known Implementing Classes:
EmptyStatsProvider, LocalPlayerStatsProvider, PlayerStatsProvider, RandomStatsProvider, ServerPlayerStatsProvider

public interface IStatsProvider
An abstraction layer over the game's native StatsCounter mechanism, for reading statistics data, primarily about players.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<net.minecraft.stats.StatType<net.minecraft.world.level.block.Block>>
    Returns an unmodifiable List of all registered StatTypes related to Blocks.
    static net.minecraft.network.chat.MutableComponent
    getCustomStatName(net.minecraft.resources.Identifier customStat)
    Returns the display name of a given "custom stat", also known as "general stat" in the GUI statistics menu.
    static List<net.minecraft.stats.StatType<net.minecraft.world.entity.EntityType<?>>>
    Returns an unmodifiable List of all registered StatTypes related to EntityTypes.
    default <T> int
    getIntValue(@NotNull net.minecraft.stats.StatType<T> type, T subject)
    Returns the Integer value of a given StatType and its corresponding Stat.
    <T> int
    getIntValue(net.minecraft.stats.Stat<T> stat)
    Returns the Integer value of a given Stat.
    static List<net.minecraft.stats.StatType<net.minecraft.world.item.Item>>
    Returns an unmodifiable List of all registered StatTypes related to Items.
    static net.minecraft.network.chat.Component
    getStatTypeName(net.minecraft.stats.StatType<?> statType)
    Returns the display name of a given StatType.
  • Method Details

    • getIntValue

      <T> int getIntValue(net.minecraft.stats.Stat<T> stat)
      Returns the Integer value of a given Stat.
      Parameters:
      stat - The Stat whose value is to be obtained.
      See Also:
      • StatsCounter
    • getIntValue

      @Virtual default <T> int getIntValue(@NotNull @NotNull net.minecraft.stats.StatType<T> type, @NotNull T subject) throws NullPointerException
      Returns the Integer value of a given StatType and its corresponding Stat.
      Parameters:
      type - The StatType.
      subject - The subject about whom stat value is to be obtained.
      Throws:
      NullPointerException
      See Also:
      • StatsCounter
      API Note:
      You should not override this, as it calls getIntValue(Stat) by default.
    • getItemStatTypes

      static List<net.minecraft.stats.StatType<net.minecraft.world.item.Item>> getItemStatTypes()
      Returns an unmodifiable List of all registered StatTypes related to Items.
    • getBlockStatTypes

      static List<net.minecraft.stats.StatType<net.minecraft.world.level.block.Block>> getBlockStatTypes()
      Returns an unmodifiable List of all registered StatTypes related to Blocks.
    • getEntityStatTypes

      static List<net.minecraft.stats.StatType<net.minecraft.world.entity.EntityType<?>>> getEntityStatTypes()
      Returns an unmodifiable List of all registered StatTypes related to EntityTypes.
    • getStatTypeName

      static net.minecraft.network.chat.Component getStatTypeName(net.minecraft.stats.StatType<?> statType) throws NullPointerException
      Returns the display name of a given StatType.
      Throws:
      NullPointerException - If the StatType is not registered.
    • getCustomStatName

      static net.minecraft.network.chat.MutableComponent getCustomStatName(net.minecraft.resources.Identifier customStat) throws NullPointerException
      Returns the display name of a given "custom stat", also known as "general stat" in the GUI statistics menu.
      Parameters:
      customStat - The custom/general stat.
      Throws:
      NullPointerException - If the argument is null.