message-dotsDialogue

This guide explains how to create a Dialogue NPC, how the dialogue system works internally, and how NPC behaviours affect appearance and behavior in the world.

The goal of this document is not only to show what to write, but to explain why each field exists and what problem it solves.

All examples shown below are real, tested, and working.


📁 Required Folder Structure

config/
└── CobbleBetterNPC/
    ├── NPC/
    │   └── dialogues/
    │       └── dialogue_001.json
    └── Dialogues/
        └── dialogues/
            └── dialogue_001.json

📌 Why two different folders?

CobbleBetterNPC separates responsibilities:

Folder
Purpose

NPC/

Defines the NPC entity (appearance, behaviors, interactions)

Dialogues/

Defines the conversation logic (text, pages, buttons, actions)

This separation allows:

  • Reusing the same dialogue for multiple NPCs

  • Editing dialogue text without touching the NPC entity

  • Keeping large projects organized and scalable

📌 Creating and reloading files

  • Generate example files with:

  • Apply changes without restart using:


🧍 Dialogue NPC File (Entity Definition)

📄 config/CobbleBetterNPC/NPC/dialogues/dialogue_001.json

This file defines the NPC as an entity in the world:

  • What type of NPC it is

  • How it behaves physically

  • What dialogue opens when a player interacts


🧾 NPC Fields Explained (Line by Line)

🔹 id

  • Unique identifier for the NPC

  • Must never be duplicated

  • Used internally to register and reload NPCs

  • Recommended format:


🔹 type

  • Defines how the NPC reacts to interaction

  • "dialogue" means:

    • Right-click opens a dialogue UI

circle-exclamation

🔹 resourceIdentifier

  • Defines the base entity model

  • Controls:

    • Model

    • Animations

    • Default hitbox

Examples:

  • cobblemon:standard → humanoid NPC

  • cobblemon:pikachu → Pokémon NPC


🔹 names

  • Name displayed above the NPC

  • Supports:

    • Color formatting

  • Used purely for presentation


🌍 World & Safety Settings

These fields control how the NPC behaves in the world.

Field
What it does
Why it matters

isMovable

Prevents movement

Keeps NPC in place

canDespawn

Prevents despawn

NPC is permanent

isInvulnerable

No damage

Protects NPC

isLeashable

Cannot be leashed

Prevents griefing

allowProjectileHits

Blocks arrows

Anti-trolling

hideNameTag

Shows name

Player clarity


🔁 Interaction – Dialogue Selection Logic

This section defines which dialogue opens when the player interacts.

Fields explained

Field
Purpose

name

Informational only

with

Priority (lower = checked first)

permission

Required permission (empty = everyone)

dialogue

Dialogue ID (no .json)

📌 Rule: If multiple interactions exist, the system:

1

Step 1

Sorts interactions by with (lowest first).

2

Step 2

Checks permissions for each interaction in order.

3

Step 3

Opens the first valid dialogue found.


🤖 Behaviours

Behaviours define how the NPC behaves physically, not what it says.


🧑 player_textured

  • Applies a player skin to the NPC

  • Requires the variable player_texture

Use this when:

  • Creating human NPCs

  • Representing staff or story characters


👀 looks_at_players

  • NPC rotates its head to look at nearby players

  • Improves immersion

  • Strongly recommended for dialogue NPCs


🧠 core

Provides essential base AI logic.

What it handles

  • Orientation

  • Behaviour coordination

  • Internal ticking


💬 Dialogue File (Conversation Logic)

📄 config/CobbleBetterNPC/Dialogues/dialogues/dialogue_001.json

This file defines what is said, what choices appear, and what actions are executed.


📄 Pages

Syntax:

Element
Meaning

id

Page identifier

speaker

npc or player

<player>

Automatically replaced

Pages exist to:

  • Separate dialogue states

  • Allow jumps using set_page

  • Support branching conversations


🔘 Buttons

Syntax:

Rules:

  • Buttons belong to the last page above them

  • Clicking a button executes its action


⚙️ Actions

Actions are reusable logic blocks.

Common actions:

Action
Purpose

set_page('id')

Jump to a page

run_command(...)

Execute a server command

close

Close dialogue


auto: close

  • Automatically closes the dialogue

  • Used when a page has no buttons

  • Ideal for final informational messages


🚪 quitter

  • Message shown only if the player presses ESC

  • Does not execute actions

  • Used as an exit flavor message


Last updated