Class SubjectStats<S>

java.lang.Object
com.thecsdev.commonmc.api.stats.util.SubjectStats<S>
Type Parameters:
S - The "thing" about which the statistics are. This could be something like a general-stat/item/mob.
Direct Known Subclasses:
BlockStats, CustomStat, EntityStats, ItemStats

public abstract sealed class SubjectStats<S> extends Object permits CustomStat, ItemStats, BlockStats, EntityStats
Utility for reading statistics about a given thing (aka subject).
  • Constructor Details

  • Method Details

    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(@Nullable @Nullable Object obj)
      Overrides:
      equals in class Object
    • getStatsProvider

      @NotNull public final @NotNull IStatsProvider getStatsProvider()
      The IStatsProvider instance used by this SubjectStats instance.
    • getSubject

      @NotNull public final S getSubject()
      The "thing" this SubjectStats instance is about. This could be something like a custom-id/item/mob.
    • getSubjectID

      @NotNull public final @NotNull net.minecraft.resources.Identifier getSubjectID()
      Returns the Identifier that is associated with the given getSubject() in the game's registry system.
      See Also:
      • BuiltInRegistries
    • getSubjectDisplayName

      @NotNull public abstract @NotNull net.minecraft.network.chat.Component getSubjectDisplayName()
      Returns the in-game display name of the getSubject().
    • getValues

      @NotNull public abstract @NotNull LinkedHashMap<net.minecraft.stats.Stat<S>, Integer> getValues()
      Returns all the statistics about the getSubject().
    • getValuesF

      @NotNull public final @NotNull LinkedHashMap<net.minecraft.stats.Stat<S>, String> getValuesF()
      Returns all the statistics about the getSubject(), with their values formatted using Stat.format(int).
    • getValuesF

      @NotNull public final @NotNull LinkedHashMap<net.minecraft.stats.Stat<S>, String> getValuesF(@NotNull @NotNull StatFormatterOverride formatter) throws NullPointerException
      Returns all the statistics about the getSubject(), with their values formatted using a custom formatter.
      Parameters:
      formatter - The custom formatter to use.
      Throws:
      NullPointerException - If the argument is null.
    • isEmpty

      @Virtual public boolean isEmpty()
      Returns true if all StatTypes for the given getSubject() have the value 0.
    • isSearchMatch

      @Virtual public boolean isSearchMatch(@NotNull @NotNull String query) throws NullPointerException
      Returns true if this getSubject() matches a given search query.
      Parameters:
      query - The search query.
      Throws:
      NullPointerException