Class StatsViewUtils

java.lang.Object
com.thecsdev.betterstats.api.mcbs.view.statsview.StatsViewUtils

@Environment(CLIENT) public final class StatsViewUtils extends Object
Utilities for initializing StatsView GUI interfaces.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.resources.Identifier
    StatsView.Filters key for the "Show empty stats" filter.
    static final net.minecraft.resources.Identifier
    StatsView.Filters key for the "Search..." filter.
    static final net.minecraft.resources.Identifier
    StatsView.Filters key for the "Current StatsView" filter.
    static final int
    The default horizontal and vertical margin that is commonly used for various GUI elements on McbsEditorGUIs.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final void
    initBlockStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.BlockStats> blockStats)
    Initializes a collection of "Block" statistics in a given "group".
    static final void
    initBlockStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.BlockStats> blockStats, @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TBlockStatsWidget> widgetPostProcessor)
    Initializes a collection of "Block" statistics in a given "group".
    static final void
    initBooleanFilter(StatsView.FiltersInitContext context, @NotNull net.minecraft.resources.Identifier filterId, boolean defaultValue, @NotNull net.minecraft.network.chat.Component labelText)
    Initializes a TCheckboxWidget for a given boolean type filter.
    static void
    Initializes the default user-interface for a StatsView's "Filters" panel.
    static final void
    initGeneralStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.CustomStat> customStats)
    Initializes a collection of "General" statistics in a given "group".
    static final void
    initGeneralStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.CustomStat> customStats, @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TCustomStatWidget> widgetPostProcessor)
    Initializes a collection of "General" statistics in a given "group".
    static final @NotNull com.thecsdev.commonmc.api.client.gui.label.TLabelElement
    initGroupLabel(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @NotNull net.minecraft.network.chat.Component text)
    Creates and adds a TLabelElement to the TPanelElement, positioned at the bottom of the panel's TElement.getContentBounds(), and taking up full panel width.
    static final Map.Entry<com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement, com.thecsdev.commonmc.api.client.gui.label.TLabelElement>
    initGroupLabelFramed(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @NotNull net.minecraft.network.chat.Component text, double textScale)
    Creates and adds a "framed" label to the TPanelElement, positioned at the bottom of the panel's TElement.getContentBounds(), and taking up full panel width.
    static final void
    initItemStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.ItemStats> itemStats)
    Initializes a collection of "Item" statistics in a given "group".
    static final void
    initItemStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.ItemStats> itemStats, @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TItemStatsWidget> widgetPostProcessor)
    Initializes a collection of "Item" statistics in a given "group".
    static final void
    initMobStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.EntityStats> mobStats)
    Initializes a collection of "Mob" statistics in a given "group".
    static final void
    initMobStats(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.EntityStats> mobStats, @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TEntityStatsWidget> widgetPostProcessor)
    Initializes a collection of "Mob" statistics in a given "group".
    static final void
    Initializes the TSimpleTextFieldWidget "Search" filter that filters statistics based on their names.
    static final void
    Initializes the TCheckboxWidget "Show all stats" filter that shows statistics whose values are "0".
    static final void
    Initializes the StatsView selection dropdown widget.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GAP

      public static final int GAP
      The default horizontal and vertical margin that is commonly used for various GUI elements on McbsEditorGUIs.
      See Also:
    • FID_STATSVIEW

      public static final net.minecraft.resources.Identifier FID_STATSVIEW
      StatsView.Filters key for the "Current StatsView" filter.

      Filter value type: StatsView

    • FID_EMPTYSTATS

      public static final net.minecraft.resources.Identifier FID_EMPTYSTATS
      StatsView.Filters key for the "Show empty stats" filter.

      Filter value type: Boolean

  • Method Details

    • initGroupLabel

      @Contract("_, _ -> new") @NotNull public static final @NotNull com.thecsdev.commonmc.api.client.gui.label.TLabelElement initGroupLabel(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @NotNull @NotNull net.minecraft.network.chat.Component text) throws NullPointerException
      Creates and adds a TLabelElement to the TPanelElement, positioned at the bottom of the panel's TElement.getContentBounds(), and taking up full panel width.
      Parameters:
      panel - The target TPanelElement.
      text - The label's text.
      Throws:
      NullPointerException - If an argument is null.
    • initGroupLabelFramed

      @Internal @Experimental @NotNull public static final Map.Entry<com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement, com.thecsdev.commonmc.api.client.gui.label.TLabelElement> initGroupLabelFramed(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @NotNull @NotNull net.minecraft.network.chat.Component text, double textScale) throws NullPointerException
      Creates and adds a "framed" label to the TPanelElement, positioned at the bottom of the panel's TElement.getContentBounds(), and taking up full panel width.

      The "frame" is a TFillColorElement with the TLabelElement as its child.

      Parameters:
      panel - The target TPanelElement.
      text - The label's text.
      textScale - The label's text scale.
      Throws:
      NullPointerException - If an argument is null.
      See Also:
    • initDefaultFilters

      public static void initDefaultFilters(@NotNull StatsView.FiltersInitContext context)
      Initializes the default user-interface for a StatsView's "Filters" panel.
      Parameters:
      context - The StatsView.FiltersInitContext.
      Throws:
      NullPointerException - If the argument is null.
    • initStatsViewFilter

      public static final void initStatsViewFilter(@NotNull StatsView.FiltersInitContext context) throws NullPointerException
      Initializes the StatsView selection dropdown widget.
      Parameters:
      context - The StatsView.FiltersInitContext.
      Throws:
      NullPointerException - If the argument is null.
    • initSearchFilter

      public static final void initSearchFilter(@NotNull StatsView.FiltersInitContext context) throws NullPointerException
      Initializes the TSimpleTextFieldWidget "Search" filter that filters statistics based on their names.
      Parameters:
      context - The StatsView.FiltersInitContext.
      Throws:
      NullPointerException - If the argument is null.
    • initShowAllStatsFilter

      public static final void initShowAllStatsFilter(@NotNull StatsView.FiltersInitContext context) throws NullPointerException
      Initializes the TCheckboxWidget "Show all stats" filter that shows statistics whose values are "0".
      Parameters:
      context - The StatsView.FiltersInitContext.
      Throws:
      NullPointerException - If the argument is null.
    • initBooleanFilter

      public static final void initBooleanFilter(@NotNull StatsView.FiltersInitContext context, @NotNull @NotNull net.minecraft.resources.Identifier filterId, boolean defaultValue, @NotNull @NotNull net.minecraft.network.chat.Component labelText) throws NullPointerException
      Initializes a TCheckboxWidget for a given boolean type filter.
      Parameters:
      context - The StatsView.FiltersInitContext.
      filterId - The unique Identifier for the filter.
      defaultValue - The filter's default value.
      labelText - The checkbox label text.
      Throws:
      NullPointerException - If an argument is null.
    • initGeneralStats

      public static final void initGeneralStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.CustomStat> customStats) throws NullPointerException
      Initializes a collection of "General" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      customStats - The "General" statistics collection.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initGeneralStats

      public static final void initGeneralStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.CustomStat> customStats, @Nullable @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TCustomStatWidget> widgetPostProcessor) throws NullPointerException
      Initializes a collection of "General" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      customStats - The "General" statistics collection.
      widgetPostProcessor - An optional post-processor for each created TCustomStatWidget.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initItemStats

      public static final void initItemStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.ItemStats> itemStats) throws NullPointerException
      Initializes a collection of "Item" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      itemStats - The "Item" statistics collection.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initItemStats

      public static final void initItemStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.ItemStats> itemStats, @Nullable @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TItemStatsWidget> widgetPostProcessor) throws NullPointerException
      Initializes a collection of "Item" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      itemStats - The "Item" statistics collection.
      widgetPostProcessor - An optional post-processor for each created TItemStatsWidget.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initBlockStats

      public static final void initBlockStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.BlockStats> blockStats) throws NullPointerException
      Initializes a collection of "Block" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      blockStats - The "Block" statistics collection.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initBlockStats

      public static final void initBlockStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.BlockStats> blockStats, @Nullable @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TBlockStatsWidget> widgetPostProcessor) throws NullPointerException
      Initializes a collection of "Block" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      blockStats - The "Block" statistics collection.
      widgetPostProcessor - An optional post-processor for each created TBlockStatsWidget.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initMobStats

      public static final void initMobStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.EntityStats> mobStats) throws NullPointerException
      Initializes a collection of "Mob" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      mobStats - The "Mob" statistics collection.
      Throws:
      NullPointerException - If a NotNull argument is null.
    • initMobStats

      public static final void initMobStats(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement panel, @Nullable @Nullable net.minecraft.network.chat.Component groupLabel, @NotNull @NotNull Iterable<com.thecsdev.commonmc.api.stats.util.EntityStats> mobStats, @Nullable @Nullable Consumer<com.thecsdev.commonmc.api.client.gui.widget.stats.TEntityStatsWidget> widgetPostProcessor) throws NullPointerException
      Initializes a collection of "Mob" statistics in a given "group".
      Parameters:
      panel - The TPanelElement where the stats initialize.
      groupLabel - The display name of the group of statistics.
      mobStats - The "Mob" statistics collection.
      widgetPostProcessor - An optional post-processor for each created TEntityStatsWidget.
      Throws:
      NullPointerException - If a NotNull argument is null.