Enum SpawnGroup

java.lang.Object
java.lang.Enum<SpawnGroup>
net.minecraft.entity.SpawnGroup
All Implemented Interfaces:
Serializable, Comparable<SpawnGroup>, java.lang.constant.Constable, StringIdentifiable

public enum SpawnGroup
extends Enum<SpawnGroup>
implements StringIdentifiable
A spawn group represents the category of an entity's natural spawning.

Entities that don't support natural spawning belong to the MISC group.

See Also:
EntityType.getSpawnGroup(), SpawnHelper
  • Enum Constant Details

    • MONSTER

      public static final SpawnGroup MONSTER
    • CREATURE

      public static final SpawnGroup CREATURE
    • AMBIENT

      public static final SpawnGroup AMBIENT
    • WATER_CREATURE

      public static final SpawnGroup WATER_CREATURE
    • WATER_AMBIENT

      public static final SpawnGroup WATER_AMBIENT
    • MISC

      public static final SpawnGroup MISC
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<SpawnGroup> CODEC
      A codec that encodes and decodes a spawn group from and to its name string.
    • BY_NAME

      private static final Map<String,​SpawnGroup> BY_NAME
    • capacity

      private final int capacity
    • peaceful

      private final boolean peaceful
    • rare

      private final boolean rare
    • name

      private final String name
    • despawnStartRange

      private final int despawnStartRange
      See Also:
      Constant Field Values
    • immediateDespawnRange

      private final int immediateDespawnRange
  • Constructor Details

    • SpawnGroup

      private SpawnGroup​(String name, int spawnCap, boolean peaceful, boolean rare, int immediateDespawnRange)
  • Method Details

    • values

      public static SpawnGroup[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static SpawnGroup valueOf​(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getName

      public String getName()
      Returns the name of this spawn group.

      The names are unique and are in lower_snake_case.

    • asString

      public String asString()
      Specified by:
      asString in interface StringIdentifiable
    • byName

      public static SpawnGroup byName​(String name)
      Finds the spawn group with the given name, or null if no group has the given name.
      Parameters:
      name - the name of the group
      Returns:
      the found group, or null
      See Also:
      getName()
    • getCapacity

      public int getCapacity()
      Returns the maximum number of mobs in this group that can be spawned per chunk.
    • isPeaceful

      public boolean isPeaceful()
      Returns true if this group is spawned as animals, or false if this group is spawned as monsters.
      See Also:
      World.setMobSpawnOptions(boolean, boolean)
    • isRare

      public boolean isRare()
      Returns if this spawn group is spawned only rarely.

      A rare spawn only happens when the world time is a multiple of 400 in ServerChunkManager.tickChunks().

    • getImmediateDespawnRange

      public int getImmediateDespawnRange()
      Returns the distance, of a mob of this group from a player, at which that mob will despawn immediately.

      This is ignored if a mob cannot immediately despawn.

      See Also:
      MobEntity.checkDespawn()
    • getDespawnStartRange

      public int getDespawnStartRange()
      Returns the distance, of a mob of this group from a player, at which that mob can despawn at chance.

      This is ignored if a mob cannot immediately despawn.

      See Also:
      MobEntity.checkDespawn()