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
roleBuilderInfoyesNPC role to spawn
countIntegerno1Number of NPCs to spawn (> 0)
radiusDoubleno8.0Scatter radius for multiple spawns (> 0)
flagsStringno"none"Comma-separated debug flags to apply
speedDoublenoInitial velocity magnitude in player’s look direction (> 0)
--nonrandomflagnoUse deterministic random seed (seed 0)
positionStringnoExplicit spawn position as "x,y,z"
posOffsetStringnoPosition offset as "x,y,z"
headRotationStringnoHead rotation as "x,y,z" (freezes NPC)
bodyRotationStringnoBody rotation as "x,y,z"
--randomRotationflagnoRandom Y-axis rotation for each spawn
--facingRotationflagnoFace toward the player
flockStringno"1"Flock size (integer) or flock asset name
--testflagnoValidate spawn position suitability
--spawnOnGroundflagnoScatter Y offset near ground level
--frozenflagnoFreeze NPC immediately after spawn
--randomModelflagnoApply a random cosmetic skin
scaleFloatnoModel scale override
--bypassScaleLimitsflagnoIgnore 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.