Interface ISpawnerCoreStats

All Known Implementing Classes:
SpawnerCoreItem.SpawnerCoreStats

public interface ISpawnerCoreStats
Represents the entity types contained in a Spawner Core. Retrieve an instance of this with IItemRegistry.getSpawnerCoreStats(ItemStack).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addAmount(net.minecraft.world.entity.EntityType<?> type, int toAdd)
    Update the percentage level for the given entity type.
    Set<net.minecraft.world.entity.EntityType<?>>
    Get the entity types stored in this spawner core
    int
    getPercentage(net.minecraft.world.entity.EntityType<?> entityType)
    Get the percentage of the core that the given entity type occupies
    int
    Get the unoccupied percentage of the core
    net.minecraft.world.entity.EntityType<?>
    pickEntity(boolean includeUnused)
    Pick a weighted random entity from the core.
    void
    serialize(net.minecraft.world.item.ItemStack stack)
    Serialize the current stats onto the given ItemStack, which must be a Spawner Core
  • Method Details

    • getEntities

      Set<net.minecraft.world.entity.EntityType<?>> getEntities()
      Get the entity types stored in this spawner core
      Returns:
      a set of entity types
    • getPercentage

      int getPercentage(net.minecraft.world.entity.EntityType<?> entityType)
      Get the percentage of the core that the given entity type occupies
      Parameters:
      entityType - an entity type
      Returns:
      a percentage level
    • getUnusedPercentage

      int getUnusedPercentage()
      Get the unoccupied percentage of the core
      Returns:
      a percentage level
    • addAmount

      boolean addAmount(net.minecraft.world.entity.EntityType<?> type, int toAdd)
      Update the percentage level for the given entity type. The update level will be clamped so that does not go below zero, or leaves the total occupation of the core greater than 100%.

      The updated level is not automatically serialized to an ItemStack; see serialize(ItemStack) for that.

      Parameters:
      type - an entity type
      toAdd - the amount to adjust by, may be negative
      Returns:
      true if any change was made, false otherwise
    • pickEntity

      net.minecraft.world.entity.EntityType<?> pickEntity(boolean includeUnused)
      Pick a weighted random entity from the core.
      Parameters:
      includeUnused - if true, the unused percentage will be taken into account, leading to a possible null return value
      Returns:
      an entity type, or null if no entity type was selected
    • serialize

      void serialize(net.minecraft.world.item.ItemStack stack)
      Serialize the current stats onto the given ItemStack, which must be a Spawner Core
      Parameters:
      stack - an ItemStack
      Throws:
      IllegalArgumentException - if the ItemStack is not a Spawner Core