Pathfinding

Pathfinding is the ability to make an entity walk to a specific location, or set of locations. Echo has this ability, both as a Transition, and Custom Component.

Pathfinding works by using the existing Minecraft pathfinding behavior, and dummy entities. We will create invisible entities, place them into the world as target, and then pathfinding to them.

Template

{
    "header": {
        "output_type": "dev",
        "default_state": "start",
        "manifest_id": "488f3a14-3427-4cc4-9af3-2e95970b3c9d",
        "create_entities": [
            "target example_target"
        ]
    },
    "states": [
        {
            "name": "start",
            "next": "arrived",
            "text": [
                "Hey there!",
                "Welcome to Echo:NPC!",
                "Lets take a walk, shall we?",
                "We have arrived!"
            ],
            "transitions": {
                "4": "pathfinding example_target"
            }
        }
    ],
    "entity": "default sirlich:knight"
}

With Comments

{
    "header": {
        "output_type": "dev",
        "default_state": "start",
        "manifest_id": "488f3a14-3427-4cc4-9af3-2e95970b3c9d",
        //We can create extra entities using the create_entities macro.
        //This will create new entities based on entity_templates, just like the main "entity" key.
        //'target' is the template, and example_target is the argument
        //---
        //The target template will create a new entity called echo:example_target with the family
        //name of 'example_target'.
        "create_entities": [
            "target example_target"
        ]
    },
    "states": [
        {
            "name": "start",
            "next": "arrived",
            "text": [
                "Hey there!",
                "Welcome to Echo:NPC!",
                "Lets take a walk, shall we?",
                "We have arrived!"
            ],
            "transitions": {
                //Pathfinding can be utilized as a transition. In this case, the entity will walk
                //towards our dummy entity, and say "We have Arrived" when it gets close enough.
                //---
                //Note that we incude this transition on sub-state FOUR not sub-state 3.
                //This is because the pathfinding components give our ability to walk. If we place
                //These components on sub-state 3, the entity will begin walking too early!
                "4": "pathfinding example_target"
            }
        }
    ],
    "entity": "default sirlich:knight"
}