Class StatsUtil

java.lang.Object
com.minecolonies.api.util.StatsUtil

public class StatsUtil extends Object
A variety of helper functions to facilitate statistics collection by buildings.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    trackStat(IBuilding building, String statIdentifier, int count)
    Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
    static void
    trackStatByName(IBuilding building, String statIdentifier, String displayName, int count)
    Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
    static void
    trackStatByName(IBuilding building, String statIdentifier, net.minecraft.network.chat.Component displayName, int count)
    Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
    static void
    trackStatByStack(IBuilding building, String statIdentifier, net.minecraft.world.item.ItemStack stack, int count)
    Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
    static void
    trackStatByStackMap(IBuilding building, String statName, it.unimi.dsi.fastutil.objects.Object2IntMap<net.minecraft.world.item.ItemStack> itemMap)
    Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
    static void
    trackStatFromFurnace(IBuilding building, String statName, net.minecraft.world.level.block.entity.FurnaceBlockEntity furnace, int slot)
    Tracks a statistic for a given building based on the items in a furnace slot.

    Methods inherited from class java.lang.Object

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

    • StatsUtil

      public StatsUtil()
  • Method Details

    • trackStatFromFurnace

      public static void trackStatFromFurnace(IBuilding building, String statName, net.minecraft.world.level.block.entity.FurnaceBlockEntity furnace, int slot)
      Tracks a statistic for a given building based on the items in a furnace slot. Retrieves the item from the specified slot in the furnace, and if an item is present, tracks the statistic using the item's display name and count.
      Parameters:
      building - the building to track the stat for.
      statName - the identifier for the stat.
      furnace - the furnace block entity to retrieve the item from.
      slot - the slot number in the furnace to check for items.
    • trackStatByStackMap

      public static void trackStatByStackMap(IBuilding building, String statName, it.unimi.dsi.fastutil.objects.Object2IntMap<net.minecraft.world.item.ItemStack> itemMap)
      Track a stat for a given building using the standard STATS_MODULE, with some null safety built in. Takes a map of ItemStacks and the total amounts of those stacks to be added to the stats and calls overridden individual trackStat methods on each of them.
      Parameters:
      building - the building to track the stat for.
      statName - the identifier for the stat.
      itemMap - the items to track the stats for.
    • trackStatByStack

      public static void trackStatByStack(IBuilding building, String statIdentifier, net.minecraft.world.item.ItemStack stack, int count)
      Track a stat for a given building using the standard STATS_MODULE, with some null safety built in.
      Parameters:
      building - the building to track the stat for.
      statIdentifier - the identifier for the stat.
      stack - the ItemStack to track the stat for (displayName will be read from the descriptionId)
      count - the number of the item to track the stat for.
    • trackStatByName

      public static void trackStatByName(IBuilding building, String statIdentifier, String displayName, int count)
      Track a stat for a given building using the standard STATS_MODULE, with some null safety built in. Used for a stats where the category has a detailed breakdown by name.
      Parameters:
      building - the building to track the stat for.
      statIdentifier - the identifier for the stat.
      displayName - the display name of the item to track the stat for.
      count - the number of the item to track the stat for.
    • trackStatByName

      public static void trackStatByName(IBuilding building, String statIdentifier, net.minecraft.network.chat.Component displayName, int count)
      Track a stat for a given building using the standard STATS_MODULE, with some null safety built in. Used for a stats where the category has a detailed breakdown by name.
      Parameters:
      building - the building to track the stat for.
      statIdentifier - the identifier for the stat.
      displayName - the display name of the item to track the stat for, as a Component.
      count - the number of the item to track the stat for.
    • trackStat

      public static void trackStat(IBuilding building, String statIdentifier, int count)
      Track a stat for a given building using the standard STATS_MODULE, with some null safety built in. Used for a simple category count - with no additional breakdown by name.
      Parameters:
      building - the building to track the stat for.
      statIdentifier - the identifier for the stat.
      count - the number of the item to track the stat for.