Skip to content

NPC Spawn Schema

Class: com.hypixel.hytale.server.spawning.assets.spawns.config.NPCSpawn Codec: BuilderCodec<NPCSpawn> (abstract, via AssetBuilderCodec.abstractBuilder)

NPC spawn definitions control which NPCs can spawn, under what environmental conditions (time of day, moon phase, light levels), and how they despawn. NPCSpawn is an abstract class; the base codec (BASE_CODEC) defines the shared fields documented here. Subclasses extend this codec for specific spawn mechanisms. Most fields use appendInherited, enabling asset pack inheritance chains.

JSON KeyJava TypeJSON TypeRequiredDefaultDescription
NPCsRoleSpawnParameters[]array of objectsyesA required list of role spawn parameters defining each NPC that can be spawned and their relative weights. Must be non-null and non-empty. See RoleSpawnParameters sub-schema below.
DespawnDespawnParametersobjectnonullOptional despawn parameters to control NPC despawning. See DespawnParameters sub-schema below.
JSON KeyJava TypeJSON TypeRequiredDefaultDescription
DayTimeRangedouble[]array of 2 numbersno[0.0, Double.MAX_VALUE]Hour range within which the NPCs will spawn (between 0 and 24). Default is unbounded (always spawns). Values are divided by 24 internally to normalize to a 0-1 range. Must contain exactly 2 elements, both >= 0.
MoonPhaseRangeint[]array of 2 integersno[0, Integer.MAX_VALUE]Moon phase range during which the NPCs will spawn. Default is unbounded (all phases). Must contain exactly 2 elements, both >= 0.
ScaleDayTimeRangeBooleanbooleannotrueIf true, instead of using absolute hour values for DayTimeRange, it will be scaled based on the world’s DaytimePortion. 0 and 24 represent the middle of the night portion. 6 represents sunrise. 12 represents the middle of the day portion. 18 represents sunset.
JSON KeyJava TypeJSON TypeRequiredDefaultDescription
LightRangesMap<LightType, double[]>object (enum keys -> arrays of numbers)nonullOptional light ranges to constrain spawning, defined between 0 and 100. Values must be weakly monotonic. When absent, the full range [0, 100] is used for all light types. Keys are LightType enum values (see below).
ValueDescription
LightTotal light level.
SkyLightLight level based on how deep under cover the position is relative to the open sky (e.g., inside a cave will be low SkyLight).
SunlightLight level based on time of day (peaks at around noon and is 0 during most of the night).
RedLightRed light level.
GreenLightGreen light level.
BlueLightBlue light level.

Each entry in the NPCs array is a RoleSpawnParameters object defining a single NPC type and its spawn configuration:

JSON KeyJava TypeJSON TypeRequiredDescription
IdStringstringyesThe Role ID of the NPC to spawn. Must be non-null and pass NPCRoleValidator.
WeightDoublenumber (>0)yesThe relative weight of this NPC. Chance of being spawned is this value relative to the sum of all weights. Must be greater than 0.
SpawnBlockSetStringstringnoAn optional BlockSet reference that defines which blocks this NPC can spawn on.
SpawnFluidTagStringstringnoAn optional tag reference that defines which fluids this NPC can spawn on.
FlockStringstringnoThe optional flock definition to spawn around this NPC. References a FlockAsset.

The Despawn field is a DespawnParameters object that controls when spawned NPCs should despawn:

JSON KeyJava TypeJSON TypeRequiredDescription
DayTimeRangedouble[]array of 2 numbersnoHour range within which NPCs will despawn (between 0 and 24). For spawn beacons, this refers to the beacon itself. Values are divided by 24 internally. Must contain exactly 2 elements, both >= 0.
MoonPhaseRangeint[]array of 2 integersnoMoon phase range during which NPCs will despawn. For spawn beacons, this refers to the beacon itself. Must contain exactly 2 elements, both >= 0.

The codec enforces these validation constraints:

  • DayTimeRange values must be >= 0
  • MoonPhaseRange values must be >= 0
  • All light range values must be between 0 and 100 (inclusive)
  • Light range arrays must be weakly monotonic (each value >= the previous)
  • Despawn DayTimeRange and MoonPhaseRange follow the same >= 0 constraint
  • NPCs must be non-null and non-empty
{
"NPCs": [
{
"Id": "Skeleton_Warrior",
"Weight": 3.0,
"SpawnBlockSet": "Overworld_Surface"
},
{
"Id": "Skeleton_Archer",
"Weight": 1.0
}
],
"Despawn": {
"DayTimeRange": [6.0, 18.0]
},
"DayTimeRange": [20.0, 4.0],
"MoonPhaseRange": [0, 7],
"LightRanges": {
"Light": [0.0, 40.0],
"SkyLight": [0.0, 50.0]
},
"ScaleDayTimeRange": true
}

This example spawns skeletons at night (hours 20-4), despawns them during the day (hours 6-18), only in low-light conditions, with warriors weighted 3:1 over archers.