Record Class SpawnData.MobCost

java.lang.Object
java.lang.Record
cz.jeme.bestium.api.inject.biome.SpawnData.MobCost
Record Components:
charge - how much charge this mob contributes to the spawn area
energyBudget - maximum total charge a spawn location can tolerate before blocking the spawn
Enclosing class:
SpawnData

public static record SpawnData.MobCost(double charge, double energyBudget) extends Record
Represents additional spawn constraints introduced in Minecraft 1.16 ("The Nether Update"). Mob cost prevents entities from spawning too close to each other by assigning a charge and an energy budget.

Each mob contributes its charge to nearby blocks (scaled by distance). When a new mob tries to spawn, the cumulative charge of surrounding entities is calculated. If the total exceeds the energyBudget, the mob is not allowed to spawn. This creates natural spacing between mobs.

For example, in vanilla Minecraft, endermen in warped forests use mob costs to spawn less densely.

See: Minecraft Wiki - Spawn Costs

  • Constructor Summary

    Constructors
    Constructor
    Description
    MobCost(double charge, double energyBudget)
    Creates an instance of a MobCost record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the charge record component.
    double
    Returns the value of the energyBudget record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.level.biome.MobSpawnSettings.MobSpawnCost
    Converts this SpawnData.MobCost to a MobSpawnSettings.MobSpawnCost.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MobCost

      public MobCost(double charge, double energyBudget)
      Creates an instance of a MobCost record class.
      Parameters:
      charge - the value for the charge record component
      energyBudget - the value for the energyBudget record component
  • Method Details

    • toMobSpawnCost

      @Internal public net.minecraft.world.level.biome.MobSpawnSettings.MobSpawnCost toMobSpawnCost()
      Converts this SpawnData.MobCost to a MobSpawnSettings.MobSpawnCost.
      Returns:
      the NMS representation of this mob cost
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • charge

      public double charge()
      Returns the value of the charge record component.
      Returns:
      the value of the charge record component
    • energyBudget

      public double energyBudget()
      Returns the value of the energyBudget record component.
      Returns:
      the value of the energyBudget record component