bedrock-kit
    Preparing search index...

    Class SpawnRule

    Represents a spawn rule file from the behavior pack's spawn_rules/ directory. Spawn rules define when and where an entity can naturally spawn in the world.

    Access via entity.spawnRule on a unified Entity.

    const entity = addon.entities.get("minecraft:zombie");
    console.log(entity?.spawnRule?.biomeTags); // ["monster", "overworld"]
    console.log(entity?.spawnRule?.entity?.id); // "minecraft:zombie"

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Constructors

    • Parameters

      • id: string
      • filePath: string
      • data: Record<string, unknown>
      • rawText: string
      • addon: AddOn

      Returns SpawnRule

    Properties

    data: Record<string, unknown>

    The raw parsed JSON data of the asset file.

    docstrings: CommentBlock[]

    All JSDoc-style comment blocks parsed from this asset's source file, in document order. Empty array when no /** … */ blocks are present.

    filePath: string

    Absolute path to the asset's file on disk. Empty string in browser mode.

    id: string

    The namespaced entity identifier this spawn rule applies to, e.g. "minecraft:zombie".

    Accessors

    • get biomeTags(): string[]

      All biome tag values referenced in this spawn rule's minecraft:biome_filter conditions. Used to match biomes — e.g. "monster", "savanna", "mesa". Deduplicated.

      Returns string[]

    • get entity(): Entity

      The unified entity this spawn rule belongs to. undefined if the entity is not present in the addon.

      Returns Entity