Spawner

Alegacy VS Quest provides a configurable block-based Quest Spawner that can spawn regular mobs or bosses. Spawned entities are tagged with the spawner position so the spawner can track them.

  • Block: alegacyvsquest:questspawner
  • Block class: BlockQuestSpawner
  • Block entity: BlockEntityQuestSpawner

Default Settings

Default attributes defined in resources/assets/alegacyvsquest/blocktypes/questspawner.json:

AttributeDefaultDescription
maxAlive3Maximum living entities from this spawner at once
spawnIntervalSeconds10How often the spawner attempts to spawn
spawnRadius4Random spawn radius around the block (in blocks)
leashRange12Counting range fallback / mob leash range
yOffset0Y offset added to spawn height

Interactions

Open Config UI

Right-click the block to open the config UI (QuestSpawnerConfigGui).

Quick Toggle (Enable/Disable)

Sneak + right-click toggles enabled state without opening UI. Internally, the spawner is considered disabled if maxAlive <= 0.

Quick Add from Entity Spawner Item

If you right-click the spawner while holding alegacyvsquest:entityspawner in the active hotbar slot:

  • The spawner will append a spawn entry based on the item attribute type
  • You will get a chat notification: Added spawn entry / Spawn entry already exists

Spawn Flow

graph TD
    A[Spawner tick] --> B{maxAlive > 0?}
    B -->|No| Z[Skip]
    B -->|Yes| C{Alive count < maxAlive?}
    C -->|No| Z
    C -->|Yes| D{Spawn interval elapsed?}
    D -->|No| Z
    D -->|Yes| E{Boss respawn timer active?}
    E -->|Yes| Z[Block spawn —
boss on cooldown] E -->|No| F[Pick random entry
by weight] F --> G[Compute spawn pos:
RainMapHeight + yOffset] G --> H[Spawn entity] H --> I[Tag with spawner Pos:
dim, x, y, z] I --> J{targetId set?} J -->|Yes| K[Set killaction:targetid] J -->|No| L[Done] K --> L

Config Fields

The spawner stores its config in block entity tree attributes:

KeyDescription
vsquest:questspawner:maxAliveMaximum living entities
vsquest:questspawner:spawnIntervalSecondsSpawn interval
vsquest:questspawner:spawnRadiusSpawn radius
vsquest:questspawner:leashRangeLeash/counting range
vsquest:questspawner:yOffsetY offset for spawn height
vsquest:questspawner:entriesSpawn table entries

Spawn Height

Spawn Y is computed as: RainMapHeightAt(x, z) + yOffset

Entries Format (Weighted Spawn Table)

The main configuration is entries (one per line):

  • Full format: entityCode|targetId|weight
  • Short format: entityCode

Where:

  • entityCode — entity asset code (e.g. game:wolf or yourmod:bossname)
  • targetId — optional ID used for kill/objective tracking
  • weight — integer weight for random selection

💡 If weight is 0 or negative, the entry is ignored. If targetId is omitted, it is not set on the entity.

Example entries

game:wolf|forest-wolf|5
game:drifter-normal|cave-drifter|3
game:drifter-deep|deep-drifter|2
yourmod:mini-boss|event-boss|1

Selection odds: wolf 5/11, drifter-normal 3/11, drifter-deep 2/11, mini-boss 1/11.

Spawned Entity Tagging

When the spawner creates an entity, it tags it with the spawner block position using EntityBehaviorQuestTarget.SetSpawnerAnchor(entity, Pos).

The spawner counts and manages entities by scanning loaded entities for these watched attribute keys:

  • alegacyvsquest:spawner:dim
  • alegacyvsquest:spawner:x
  • alegacyvsquest:spawner:y
  • alegacyvsquest:spawner:z

This is why the spawner can reliably count its own spawned mobs even if they wander away.

Kill/Objective Integration (targetId)

If targetId is present in an entry, the spawner sets:

alegacyvsquest:killaction:targetid = targetId

This can be used by kill-based objectives/actions that look for a specific target ID (e.g. killactiontarget objective).

Objective example:

{
  "id": "killactiontarget",
  "args": ["forest-wolf", "5", "false", "true"]
}

This tracks only wolves spawned by this spawner (not wild wolves).

Boss Respawn Safety

To avoid duplicate boss spawning when a boss has a respawn timer, the spawner will block spawning if it detects a dead spawned entity with alegacyvsquest:bossrespawnAtTotalHours set.

This prevents race conditions between the spawner and boss respawn logic.

Admin Buttons (UI)

The config UI includes:

  • Enable/Disable — toggles enabled state
  • Kill — despawns all entities currently tagged with this spawner position
  • Save — saves current config to the block entity

Complete Example

BlockEntity setup (via creative UI or API)

maxAlive: 5
spawnIntervalSeconds: 15
spawnRadius: 6
yOffset: 2
entries:
  game:drifter-normal|horde-drifter|4
  game:drifter-bow|horde-archer|2
  yourmod:elite-drifter|horde-elite|1

Quest integration

{
  "id": "yourmod:horde-assault",
  "stages": [
    {
      "name": "Clear the horde",
      "objectives": [
        { "id": "killactiontarget", "args": ["horde-drifter", "10", "false", "true"] },
        { "id": "killactiontarget", "args": ["horde-archer", "5", "false", "true"] },
        { "id": "killactiontarget", "args": ["horde-elite", "1", "false", "true"] }
      ]
    }
  ]
}

💡 Use yOffset to make mobs spawn above ground (e.g. yOffset: 2 for flying enemies).

Press ESC to close