Skip to content

NPCSpawnCommand

Package: com.hypixel.hytale.server.npc.commands

public class NPCSpawnCommand extends AbstractPlayerCommand

Implements /npc spawn. Spawns one or more NPCs of a specified role at or near the player’s position. The most feature-rich NPC command, supporting count, radius, debug flags, velocity, position overrides, rotation options, flock spawning, model scaling, random skins, spawn validation, and freeze-on-spawn.

ArgumentTypeRequiredDefaultDescription
roleBuilderInfoyes—NPC role to spawn
countIntegerno1Number of NPCs to spawn (> 0)
radiusDoubleno8.0Scatter radius for multiple spawns (> 0)
flagsStringno"none"Comma-separated debug flags to apply
speedDoubleno—Initial velocity magnitude in player’s look direction (> 0)
--nonrandomflagno—Use deterministic random seed (seed 0)
positionStringno—Explicit spawn position as "x,y,z"
posOffsetStringno—Position offset as "x,y,z"
headRotationStringno—Head rotation as "x,y,z" (freezes NPC)
bodyRotationStringno—Body rotation as "x,y,z"
--randomRotationflagno—Random Y-axis rotation for each spawn
--facingRotationflagno—Face toward the player
flockStringno"1"Flock size (integer) or flock asset name
--testflagno—Validate spawn position suitability
--spawnOnGroundflagno—Scatter Y offset near ground level
--frozenflagno—Freeze NPC immediately after spawn
--randomModelflagno—Apply a random cosmetic skin
scaleFloatno—Model scale override
--bypassScaleLimitsflagno—Ignore model min/max scale limits
  1. Validates the role via NPCPlugin.forceValidation() and testAndValidateRole(). Throws GeneralCommandException if validation fails.
  2. For each spawn iteration:
    • Retrieves or creates the role builder. Verifies it implements ISpawnableWithModel and is spawnable.
    • If --test flag is set, validates the spawn position using SpawningContext.
    • Spawns the NPC via NPCPlugin.spawnEntity().
    • Optionally spawns a flock via FlockPlugin.trySpawnFlock().
    • Applies head rotation, position scatter, velocity, freeze state, and debug flags.
  3. Logs each successful spawn with role name, UUID, and position.

Also provides a usage variant SpawnPageCommand that opens the entity spawn UI page.

private static final double PLAYER_FOOT_POINT_EPSILON = 0.01
public NPCSpawnCommand()

Registers as sub-command "spawn" with translation key "server.commands.npc.spawn.desc". Adds SpawnPageCommand as a usage variant.

ClassDescription
NPCSpawnCommand.SpawnPageCommandOpens the entity spawn UI page
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.