Using Custom Entities

This example shows a fairly complicated, but fully featured quest NPC.

Template

{
    "header": {
        "output_type": "here",
        "default_state": "main"
    },
    "states": [
        {
            "name": "main",
            "next": "wait_for_item",
            "transitions": {
                "1": ["proximity 10"]
            },
            "text": [
                "Hey you! Come over here!",
                "You look like a strong adventurer! §7§o[Hint: Click to Talk]",
                "Are you interested in completing a small task for me?",
                "I will reward you well!",
                "Just fetch me a stone block, and I will reward you."
            ]
        },
        {
            "name": "wait_for_item",
            "next": "reward",
            "transitions": {
                "all": [
                    "interact_with_item stone",
                    "interact echo:still_waiting"
                ]
            }
        },
        {
            "name": "still_waiting",
            "type": "single",
            "commands": [
                "/say Did you bring me stone? §7§o[Hint: Click with stone]",
                "@s echo:wait_for_item"
            ]
        },
        {
            "name": "reward",
            "next": "loop",
            "text": [
                "Thank you, that was wonderful.",
                "Please take your reward."
            ],
            "commands": {
                "1": [
                    "!playsound random.xporb"
                ],
                "2": [
                    "/give @p iron_ingot 30"
                ]
            }
        },
        {
            "name": "loop",
            "next": "loop",
            "text": [
                "Good day",
                "Thank you for your business",
                "See you later."
            ]
        }
    ],
    "entity": "dummy echo:example"
}

With Comments

Template

{
    //Header like normal
    "header": {
        "output_type": "here",
        "default_state": "main"
    },
    "states": [
        {
            //Main state will handle the first interaction with the NPC
            "name": "main",

            //Transition into the "Fetch quest" part after the introduction
            "next": "wait_for_item",

            //The first transition should be proximity based
            //This is so the player can more quickly find/see important NPCs.
            "transitions": {
                "1": ["proximity 10"]
            },

            //Introduction text to set the stage
            "text": [
                "Hey you! Come over here!",

                //Should include a hint for the first interaction, to help people
                //understand what to do.
                "You look like a strong adventurer! §7§o[Hint: Click to Talk]",
                "Are you interested in completing a small task for me?",
                "I will reward you well!",
                "Just fetch me a stone block, and I will reward you."
            ]
        },

        //This is where the "fetch quest" part is handled.
        {
            "name": "wait_for_item",
            "transitions": {
                "all": [
                    //Transition to the reward state when click with stone 
                    "interact_with_item stone echo:reward",

                    //Transition into a special "still waiting" state if we click with the wrong item/open hand
                    //This will help remind the player what each NPC does.
                    "interact echo:still_waiting"
                ]
            }
        },
        
        //Special state, just to play some dialogue when we click with the wrong item
        //This uses the 'single' type, which is perfect for this kind of interaction
        //As soon as you enter the state, the commands section will run
        //The commands section includes a transition back into wait_for_item
        {
            "name": "still_waiting",
            "type": "single",
            "commands": [
                "/say Did you bring me stone? §7§o[Hint: Click with stone]",
                "@s echo:wait_for_item"
            ]
        },

        //Reward state is pretty simple. Just a little play-sound and /give
        {
            "name": "reward",
            "next": "loop",
            "text": [
                "Thank you, that was wonderful.",
                "Please take your reward."
            ],
            "commands": {
                "2": [
                    "!playsound random.xporb",
                    "/give @p iron_ingot 30"
                ]
            }
        },

        //Loop will run in a circle forever, allowing our NPC to still have some
        //interactivity, even after the quest is over.
        {
            "name": "loop",
            "next": "loop",
            "text": [
                "Good day",
                "Thank you for your business",
                "See you later."
            ]
        }
    ],
    "entity": "dummy echo:example"
}