> ## Documentation Index
> Fetch the complete documentation index at: https://entities.lodemc.net/llms.txt
> Use this file to discover all available pages before exploring further.

# NPCs

> An NPC is a mob with type: npc: shopkeepers and quest givers that stand still, look at players and start conversations.

NPCs are the standing characters of your server: shopkeepers, quest givers, guides, decoration with a name. In LodeEntities an NPC is simply **a mob with `type: npc`**. It is declared, spawned, edited and removed exactly like any other mob: `/le spawn`, eggs from `/le gui`, [spawners](https://entities.lodemc.net/spawners.md), the in-game editor, `/le killall`. There are no separate NPC commands.

On top of the usual [mob fields](https://entities.lodemc.net/mob-fields.md) it gets two more:

| Field | What it does |
| :- | :- |
| `dialog` | A [conversation](https://entities.lodemc.net/dialogs.md) from `Dialogs/` that a right-click starts. |
| `look` | `true` turns its head toward the nearest player within 8 blocks. |

To make it look like a player, give it `base: player` and a `skin`; see [NPCs that look like players](#npcs-that-look-like-players).

## A shopkeeper

```yaml theme={null}
# Mobs/town/shopkeeper.yml
shopkeeper:
  type: npc
  base: villager
  display: "&eShopkeeper"
  dialog: shop_talk      # Dialogs/ conversation started on right-click
  look: true             # turns its head toward the nearest player
  ai: false              # stands where it is put
  invulnerable: true
  silent: true
  persistent: true       # saved with the world, survives restarts
  spawners:
    market:              # keeps one standing on this spot, facing west
      at: world, 120.5, 64, -40.5
      yaw: 90
      timer: { every: 5s }
      activation: { players: false }
```

`/le reload`, and within five seconds a shopkeeper is standing at the market. Right-click it and the `shop_talk` conversation starts.

## NPCs that look like players

`base: player` spawns a **mannequin**, Minecraft's player-shaped entity, and `skin` sets what it wears:

```yaml theme={null}
# Mobs/aaron/aaron.yml
aaron:
  type: npc
  base: player
  skin: SrFounder        # a player name
  display: "Aaron"
  look: true
  invulnerable: true
  persistent: true
```

`skin` takes one of three things:

| `skin` | What it wears |
| :- | :- |
| A player name, like `SrFounder` | That account's current skin. |
| A player uuid | The same, and it keeps working if the player renames. |
| A png file, like `aaron.png` | A 64x64 skin file beside the mob's file in `Mobs/`. |

A skin **file** is baked into the resource pack on `/le reload`, so players see it without anyone uploading it to a skin site. For the slim (Alex) arms, write it as a block:

```yaml theme={null}
  skin: { file: aaron.png, model: slim }
```

* A mannequin has no AI: it stands where it is put. `look: true` turns its head.
* The grey "NPC" line a mannequin normally shows under its name is hidden, so the `display` name is its only label.
* `base: player` needs **Minecraft 1.21.9 or newer**. On older versions the mob is skipped, with an error in [`/le debug`](debug).
* `skin` on any other base is ignored, with a warning in `/le debug`.

## How NPCs behave

* **Nothing is implied by `type: npc`.** Freeze it, make it invulnerable and keep it from despawning with the ordinary fields, as above. A villager NPC with `ai` left on wanders around and trades like any villager.
* **Right-click** starts the `dialog`, and the vanilla interaction (a villager's trade window) is cancelled when there is one. The mob's own `+onInteract` effect lines run as well, so an NPC can greet, give items or run commands on a click. Addons can cancel the dialog through [`NpcInteractEvent`](addon-events#npcinteractevent).
* **`look`** turns only the head of a mob with `ai: false` or a mannequin; the body follows once the head is more than 25° off the way it was spawned facing, and it settles back once nobody is near. A mob with AI on is simply asked to look at the player.
* **Fixed spots are spawners.** A spawner with the default `spawn.max` of 1 and a short timer keeps exactly one NPC standing there, facing `yaw`. A `persistent` NPC is taken back by its spawner after a restart rather than spawned a second time. One NPC can stand in many places: give it several spawners.
* **`/le killall` leaves NPCs alone** unless the filter names them: `/le killall [id=shopkeeper]`.
* `dialog` and `look` on a mob without `type: npc` are ignored, with a warning in `/le debug`.
* The free version allows 3 NPCs, counted separately from the 12 mobs. See [Licensing](https://entities.lodemc.net/licensing.md).

All of these can be set from the [Entities menu](https://entities.lodemc.net/gui.md) editor, too: **Type**, **Dialog** and **Looks at players**.

## Tuning NPC cost

The only per-tick work an NPC has is `look: true`, so this only matters on a server with a lot of looking NPCs. Two options in `config.yml`, applied on `/le reload`:

```yaml theme={null}
npc:
  look-interval: 1        # ticks between head turns
  activation-range: 48    # blocks a player must be within for an NPC to tick at all
```

`activation-range` does most of the work: an NPC with no player within that many blocks of where it was spawned is skipped, for the cost of one distance check. Keep it above 8, the distance at which NPCs notice players; `0` ticks every NPC. `look-interval` directly controls how often heads turn: `2` is usually indistinguishable and halves the work, and above about `4` turns start to look steppy.

## Upgrading from the old NPCs folder

Earlier versions had a separate NPC system with its own `/npc` commands and an `NPCs/` folder. It is converted on the first load:

* Each NPC becomes a `type: npc` mob in `Mobs/npcs/`, with the old frozen-prop settings written out (`ai: false`, `invulnerable`, `silent`, `persistent`).
* Each place it stood becomes a spawner under it.
* A copy that changed one of the settings that still exist (its display name, dialog, look) becomes a mob of its own.
* Right-click `effects:` become `run <effect> +onInteract` lines.
* Player skins, `follow`, `behaviour` and `positioning` are dropped. The console lists what was dropped for each NPC. To give a converted NPC its player look back, set `base: player` and a [`skin`](#npcs-that-look-like-players).

The original file stays beside the converted one as `<name>.yml.pre-mobs.bak`.

## Where to go

* [NPC Dialogs](https://entities.lodemc.net/dialogs.md): branching conversations with clickable replies.
* [Dialog Conditions](https://entities.lodemc.net/dialog-conditions.md): show a reply only when the player has the item, at night, mid-quest.
* [Dialog Files](https://entities.lodemc.net/dialog-files.md): big conversations split over many files.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.