> ## 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 & Dialogs

> Tell NPCs from plain mobs in code, and start branching conversations for any player.

## NPCs

[NPCs](https://entities.lodemc.net/npcs.md) are mobs with `type: npc`, so they are spawned, looked up and contributed through [`mobs()`](addon-mobs) like any other mob. `LodeEntitiesAPI.npcs()` is the same registry narrowed to them:

```java theme={null}
String npcId = LodeEntitiesAPI.npcs().npcId(clickedEntity);   // null if it isn't an NPC
boolean isNpc = LodeEntitiesAPI.npcs().isNpc(clickedEntity);
MobDefinition def = LodeEntitiesAPI.npcs().get("bob");        // null for a plain mob
Set<String> ids = LodeEntitiesAPI.npcs().ids();               // also all()
String dialog = def.getDialog();                              // also getLook(), isNpc()
```

To replace what a right-click does, cancel [`NpcInteractEvent`](addon-events#npcinteractevent): that skips the NPC's dialog, while its own `+onInteract` lines still run.

## Dialogs

Branching conversations from `Dialogs/` can be driven from code: start one from an item use, a region enter, a quest step.

```java theme={null}
LodeEntitiesAPI.dialogs().start(player, "bob_talk", npcEntity, "&6Bob"); // npc and name optional
boolean talking = LodeEntitiesAPI.dialogs().isInDialog(player);
LodeEntitiesAPI.dialogs().end(player);
```

`ids()` and `get(id)` are there too. The NPC argument is optional, so a dialog doesn't have to belong to an NPC at all.

### Dialogs speak the same effect language

Custom [conditions](https://entities.lodemc.net/extending-effects.md#custom-conditions) you register are immediately usable in dialog `conditions:` blocks, and custom [mechanics](https://entities.lodemc.net/extending-effects.md#custom-mechanics) in dialog node `effects:`. Nothing extra to wire up.

See [NPC Dialogs](https://entities.lodemc.net/dialogs.md) and [Dialog Conditions](https://entities.lodemc.net/dialog-conditions.md) for the config side.


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