Skip to content

Spawning Mobs

Tip

This feature requires Lychee.

Commands

Start a mob spawning session in an area:

/loquat spawn <area> <spawner_id> [difficulty_id]

Defining spawners

Spawner is where you define monster waves, and the monster types and the duration of each wave.

All spawners should be located in the loquat_spawners directory in a data pack.

Spawner specification

  • waves: A list of Wave.
  • difficulty (optional): The default Difficulty id. If not specified, it will be "default".

Wave specification

  • wait (optional): The wait time before the wave starts in seconds. If not specified, it will be 0.
  • timeout (optional): The timeout of the wave in seconds. If time runs out, the next wave will immediately start.
  • contextual (optional): Contextual Condition or a list of Contextual Condition. If the conditions are not met, the wave will be skipped.
  • post: Post Action or a list of Post Action. You should use the loquat:spawn action to spawn mobs, added by Loquat.

Example

```json
{
  "waves": [
    {
      "timeout": 30,
      "post": [
        {
          "type": "loquat:spawn",
          "count": 2,
          "mob": "husk"
        }
      ]
    },
    {
      "wait": 1,
      "post": [
        {
          "type": "loquat:spawn",
          "count": 2,
          "mob": {
            "type": "rabbit",
            "randomize": false,
            "attrs": {
              "hp": 20
            },
            "nbt": {
              "RabbitType": 99
            }
          }
        }
      ]
    }
  ]
}
```

loquat:spawn action

  • count: The number of mobs to spawn.
  • mob: The mob to spawn. Can be a string, or a Mob Entry.
  • zone (optional): The zone to spawn mobs in. If not specified, it will be "0".

Mob Entry specification

  • type: The entity type id of the mob.
  • randomize (optional): Whether to randomize the spawning, like giving random equipment to the mob, or transforming normal zombie to chicken jockey. If not specified, it will be true.
  • attrs (optional): A map of attributes to set on the mob. The key can be hp, movement_speed, damage, attack_speed, armor, armor_toughness, knockback_resistance, knockback, etc.
  • nbt (optional): A map of NBT tags to set on the mob.

Defining difficulties

The Difficulty is a manager that determines the amount of mobs to spawn, and scales the mob attributes based on the context.

All difficulties should be located in the loquat_difficulties directory in a data pack.

Difficulty specification

  • provider: A command that returns a number that determines which level to use. In the example below, it returns the number of players in the server.
  • levels: A list of Difficulty Level. If the number returned is greater than the number of levels, the last level will be used.

Difficulty Level specification

  • hp (optional): The scale of the mob's health. If not specified, it will be 1.
  • amount (optional): The scale of the amount of mobs to spawn. If not specified, it will be 1.

Example

data/loquat/loquat_difficulties/default.json:
```json
{
  "provider": "execute if entity @a",
  "levels": [
    {},
    {
      "amount": 2
    },
    {
      "amount": 2,
      "hp": 1.5
    },
    {
      "amount": 2,
      "hp": 2
    }
  ]
}
```

data/loquat/loquat_difficulties/boss.json:
```json
{
  "provider": "execute if entity @a",
  "levels": [
    {},
    {
      "hp": 2
    },
    {
      "hp": 3
    },
    {
      "hp": 4
    },
    {
      "hp": 5
    },
    {
      "hp": 6
    }
  ]
}
```

Tip

JSON Fragment is supported in spawner and difficulty to help you reuse code.