Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ElectroGamesDev/HyCitizens/llms.txt

Use this file to discover all available pages before exploring further.

CitizenData is the data model that describes a single NPC. Every field — from display name to combat ranges — lives here. You construct a CitizenData instance and hand it to CitizensManager methods such as addCitizen or updateCitizen to create or update Citizens in the world.

Constructor

new CitizenData(
    String id,                       // unique identifier
    String name,                     // display name (supports \n for multi-line)
    String modelId,                  // e.g. "Human", "Player"
    UUID worldUUID,                  // world to spawn in
    Vector3d position,               // spawn position
    Vector3f rotation,               // pitch/yaw/roll in radians
    float scale,                     // default 1.0
    UUID npcUUID,                    // null for new Citizens
    List<UUID> hologramLineUuids,    // null for new Citizens
    String requiredPermission,
    String noPermissionMessage,
    List<CommandAction> commandActions,
    boolean isPlayerModel,
    boolean useLiveSkin,
    String skinUsername,
    PlayerSkin cachedSkin,
    long lastSkinUpdate,
    boolean rotateTowardsPlayer
);
Pass null for npcUUID and hologramLineUuids when creating a brand-new Citizen. The manager assigns these values automatically after spawning.

Quick Start Example

Creating a Citizen programmatically
import com.electro.hycitizens.HyCitizensPlugin;
import com.electro.hycitizens.models.CitizenData;
import org.joml.Vector3d;
import org.joml.Vector3f;
import java.util.ArrayList;
import java.util.UUID;

// Grab any world UUID from the universe
UUID worldId = Universe.get().getWorlds().values().iterator().next().getWorldConfig().getUuid();

CitizenData citizen = new CitizenData(
    UUID.randomUUID().toString(),  // unique ID
    "Village Elder",               // name
    "Human",                       // model ID
    worldId,                       // world UUID
    new Vector3d(100, 64, 200),    // position
    new Vector3f(0, 0, 0),         // rotation
    1.0f,                          // scale
    null, null,                    // npcUUID, hologramUuids (null = new)
    "", "",                        // permission, permMessage
    new ArrayList<>(),             // command actions
    false, false, "", null, 0L,    // player-model fields
    true                           // rotateTowardsPlayer
);

HyCitizensPlugin.get().getCitizensManager().addCitizen(citizen, true);

Identity

Immutable unique identifier set at construction time. Use UUID.randomUUID().toString() when creating Citizens programmatically. The ID is used as the storage key and cannot be changed after creation.
Display name shown as the NPC’s nametag. Supports \n for multi-line nametags — each non-empty line becomes a separate hologram entity. Access via getName() / setName(String).
The Hytale model asset ID used to spawn the NPC entity, e.g. "Human", "Player". Access via getModelId() / setModelId(String).
UUID of the Hytale world where the Citizen will be spawned. Access via getWorldUUID() / setWorldUUID(UUID).
Slash-delimited group path for organisational hierarchy, e.g. "Town/Guards". Empty string means ungrouped. The path is normalised (back-slashes converted, leading/trailing slashes stripped). Access via getGroup() / setGroup(String).

Position & Scale

The configured spawn position. When a Citizen is teleported or wanders, the live position is tracked separately in currentPosition. Access via getPosition() / setPosition(Vector3d).
Spawn rotation in radians (pitch X, yaw Y, roll Z). Access via getRotation() / setRotation(Vector3f).
Model scale factor, clamped to the range 0.01–100.0. Default is 1.0. Access via getScale() / setScale(float).

Appearance

FieldTypeDescription
isPlayerModelbooleanWhen true the entity uses the Player model type.
useLiveSkinbooleanWhen true the skin is fetched from Mojang and refreshed every 30 minutes.
skinUsernameStringMojang username for skin lookup.
cachedSkinPlayerSkinThe last fetched skin object. null if not yet fetched.
lastSkinUpdatelongEpoch milliseconds of the last skin fetch.
Access via isPlayerModel(), isUseLiveSkin(), getSkinUsername(), getCachedSkin(), etc.
FieldTypeDefaultDescription
hideNametagbooleanfalseHides the nametag completely.
hideNpcbooleanfalseHides the NPC entity itself (only nametag remains visible if enabled).
nametagOffsetfloat0Vertical offset applied to the hologram position above the NPC head.
Access via isHideNametag(), isHideNpc(), getNametagOffset() / setNametagOffset(float).
Instead of a text hologram, a 3D model can be displayed above the NPC.
FieldTypeDefaultDescription
modelNametagEnabledbooleanfalseEnables the model nametag.
nametagModelIdString""Asset ID of the model to display.
nametagModelScalefloat1.0Scale of the nametag model.
rotateNametagTowardsPlayerbooleantrueWhen true, the model nametag rotates to face nearby players.
Access via isModelNametagEnabled(), getNametagModelId(), etc.
FieldTypeDefaultDescription
rotateTowardsPlayerbooleanfalseWhen true (and movement type is IDLE), the NPC turns to face nearby players.
lookAtDistancefloat25.0Maximum distance in blocks at which the NPC reacts to a player’s presence.
Access via getRotateTowardsPlayer() / setRotateTowardsPlayer(boolean) and getLookAtDistance() / setLookAtDistance(float).
FieldSlotDescription
npcHelmetArmor slot 0Item asset ID or null.
npcChestArmor slot 1Item asset ID or null.
npcGlovesArmor slot 2Item asset ID or null.
npcLeggingsArmor slot 3Item asset ID or null.
npcHandHotbar slot 0Item asset ID or null.
npcOffHandUtility slotItem asset ID or null (reserved).
Access via getNpcHelmet() / setNpcHelmet(String), and the equivalent getters/setters for each slot.
FieldTypeDefaultDescription
mapMarkerEnabledbooleanfalseEnables a map marker for this Citizen.
mapMarkerTypeString"PIN"Icon type. Valid values: PIN, DOT, STAR, DIAMOND, SQUARE, QUESTION, EXCLAMATION, MONEY_SYMBOL, SHOP, TRADER, CHEST, SWORD, SHIELD, HEART, HOME, NPC_TYPE, CUSTOM.
mapMarkerNameString""Label shown on the map.
mapMarkerCustomIconString""Filename of a custom .png icon (filename only, no path).
mapMarkerMaxDistancefloat0.0Max distance in blocks at which the marker is visible. 0 means always visible.
Access via isMapMarkerEnabled(), getMapMarkerType() / setMapMarkerType(String), etc.

Behavior

Controls how the NPC moves in the world. Construct with:
new MovementBehavior(
    String type,          // IDLE, WANDER, WANDER_CIRCLE, WANDER_RECT, PATROL, FOLLOW_CITIZEN
    float walkSpeed,      // default 10.0
    float runSpeed,       // default 6.0
    float wanderRadius,   // used by WANDER
    float wanderWidth,    // used by WANDER_RECT
    float wanderDepth     // used by WANDER_RECT
)
Movement TypeDescription
IDLEStands in place. Rotate-towards-player is only active in this mode.
WANDERWanders within a sphere of radius wanderRadius.
WANDER_CIRCLECircular wander pattern.
WANDER_RECTRectangular wander area defined by wanderWidth and wanderDepth.
PATROLFollows a named patrol path. Requires pathConfig.pluginPatrolPath to be set.
FOLLOW_CITIZENFollows another Citizen. Requires followCitizenId to be set.
Access via getMovementBehavior() / setMovementBehavior(MovementBehavior).
A list of AnimationBehavior objects that define timed, default, or proximity-triggered animations. Each entry specifies the animation name, slot, trigger type, interval, and optional stop behaviour. Access via getAnimationBehaviors() / setAnimationBehaviors(List).
The NPC’s base attitude toward players. Valid values: PASSIVE, NEUTRAL, AGGRESSIVE. Default is PASSIVE. Access via getAttitude() / setAttitude(String).
FieldTypeDefaultDescription
followCitizenEnabledbooleanfalseLegacy field. Movement type FOLLOW_CITIZEN is the preferred approach.
followCitizenIdString""ID of the Citizen to follow.
followDistancefloat2.0Desired separation distance in blocks when following.
Access via isFollowCitizenEnabled(), getFollowCitizenId() / setFollowCitizenId(String), getFollowDistance() / setFollowDistance(float).
Defines a time-based schedule that moves the Citizen between named locations and changes its activity (idle, wander, patrol, follow) throughout the in-game day. Access via getScheduleConfig() / setScheduleConfig(ScheduleConfig).

Interactions

Commands run when a player interacts with the Citizen. Each CommandAction has a command string, runAsServer flag, delay in seconds, interaction trigger (LEFT_CLICK, F_KEY, BOTH), and a chance percent. Access via getCommandActions() / setCommandActions(List).
Controls which commands from commandActions run per interaction. Valid values: ALL, RANDOM, SEQUENTIAL. Default is ALL. Access via getCommandSelectionMode() / setCommandSelectionMode(String).
Configuration for messages broadcast when a player interacts. Contains a list of CitizenMessage objects, a selection mode (ALL, RANDOM, SEQUENTIAL), and an enabled flag. Access via getMessagesConfig() / setMessagesConfig(MessagesConfig).
FieldTypeDescription
requiredPermissionStringPermission node required to interact. Empty string disables permission check.
noPermissionMessageStringMessage shown to players who lack the required permission.
Access via getRequiredPermission() / setRequiredPermission(String) and getNoPermissionMessage() / setNoPermissionMessage(String).
A one-time interaction that fires the first time each player interacts with this Citizen.
FieldTypeDefaultDescription
firstInteractionEnabledbooleanfalseEnables the first-interaction system.
firstInteractionCommandActionsList<CommandAction>[]Commands to run on the first interaction.
firstInteractionMessagesConfigMessagesConfigdefaultMessages to send on the first interaction.
firstInteractionCommandSelectionModeString"ALL"ALL or RANDOM.
postFirstInteractionBehaviorString"NORMAL"What happens on subsequent interactions: NORMAL, NONE.
runNormalOnFirstInteractionbooleanfalseWhen true, normal interaction commands/messages also fire on first interaction.
Access via isFirstInteractionEnabled(), getFirstInteractionCommandActions(), etc.

Combat & Health

FieldTypeDefaultDescription
takesDamagebooleanfalseWhen false the NPC is fully invulnerable.
overrideHealthbooleanfalseWhen true, uses healthAmount as the max HP.
healthAmountfloat100Max HP when overrideHealth is true.
overrideDamagebooleanfalseWhen true, uses damageAmount as the Citizen’s attack damage.
damageAmountfloat10Attack damage when overrideDamage is true.
Access via isTakesDamage(), isOverrideHealth(), getHealthAmount(), etc.
FieldTypeDefaultDescription
respawnOnDeathbooleantrueWhen true, the Citizen respawns after dying.
respawnDelaySecondsfloat5.0Seconds to wait before respawning.
Access via isRespawnOnDeath() / setRespawnOnDeath(boolean) and getRespawnDelaySeconds() / setRespawnDelaySeconds(float).
FieldTypeDefaultDescription
healthRegenEnabledbooleanfalseEnables passive health regeneration.
healthRegenAmountfloat1.0HP restored per regen tick.
healthRegenIntervalSecondsfloat5.0Seconds between regen ticks.
healthRegenDelayAfterDamageSecondsfloat5.0Seconds after taking damage before regen resumes.
Access via isHealthRegenEnabled(), getHealthRegenAmount(), etc.
Fine-grained control over combat AI parameters. Key fields:
FieldTypeDefaultDescription
attackTypeString"Root_NPC_Attack_Melee"Interaction ID used for the attack animation.
attackDistancefloat2.0Range in blocks at which the Citizen initiates an attack.
chaseSpeedfloat0.67Relative speed multiplier when chasing a target.
backOffAfterAttackbooleantrueWhen true, the Citizen backs away after attacking.
backOffDistancefloat4.0Distance to back off in blocks.
blockAbilityString"Shield_Block"Ability ID used for blocking.
blockProbabilityint500–100 percent chance to block incoming attacks.
Construct with new CombatConfig() (defaults apply) and customise via setters. Apply via setCitizenCombatConfig(citizenId, combatConfig).
Controls how and how far the NPC detects players. Key fields:
FieldTypeDefaultDescription
viewRangefloat15Visual detection range in blocks.
viewSectorfloat180Horizontal field-of-view in degrees.
hearingRangefloat8Hearing detection range in blocks.
absoluteDetectionRangefloat2Range within which detection is guaranteed regardless of LOS.
alertedRangefloat45Range within which an alerted NPC will pursue.
investigateRangefloat40Range for investigation state navigation.
Construct with new DetectionConfig() (defaults) or new DetectionConfig(boolean hostile). Apply via setCitizenDetectionConfig(citizenId, detectionConfig).
Configures waypoint-based patrol path behaviour. Key fields:
FieldTypeDefaultDescription
followPathbooleanfalseWhen true, the Citizen follows a path defined in the UI path editor.
pathNameString""Name of the UI-defined path to follow.
patrolbooleanfalseWhen true, the Citizen patrols between waypoints.
loopModeString"LOOP"Patrol end behaviour: LOOP, PING_PONG.
pluginPatrolPathString""Name of the plugin-API patrol path (used with startCitizenPatrol).
pluginPatrolSpeedfloat2.0Walk speed used during plugin-controlled patrol.
Construct with new PathConfig(). Apply via setCitizenPathConfig(citizenId, pathConfig).

Build docs developers (and LLMs) love