Interactive NPC Generator

Become an MCStacker Patreon to make these ads disappear. Head over to patreon.com/mcstacker to get this month's ad-free link.

If you know what you're doing you may edit the commands below. Modifications in the form above will overwrite your changes below. This will be what is saved into the exported datapack zip file.

Setup Commands
Run these commands once to set everything up. Run

Cleanup Commands
Run these commands if you want to remove everything relating to this NPC. Run

Main Loop

Command Sets

Become an MCStacker Patreon to make these ads disappear. Head over to patreon.com/mcstacker to get this month's ad-free link.

What is this?

This is an Interactive NPC (Non-Player Character) Generator. With this tool, you can make a Minecraft entity communicate with the player with tellraw commands. The player can then choose from one or more options. When an option is clicked a set of commands can be run. After this you can then set what the NPC says next. The NPC entity itself is not generated with this tool. You use MCStacker for that. You just need to give it a tag that corresponds to the base tag set with this tool. The generator outputs a datapack zip file for you to put in your minecraft world or server.

Potential Uses

story/narrative in adventure maps

multi-choice menu system

choose your own adventure

teleport players

minigames

give items or effects to players

Features

No mods required

Works with multiple players

Non-opped players are able to interact with NPCs

NPCs can execute many commands at once.

Tellraw clickEvents can only be triggered when in proximity to the NPC

Outputs a single datapack.zip file.

You can directly edit the generated function files before exporting the datapack.

You can tag the main function to run in minecraft\tags\functions\tick.json or run it in a repeating command block.

You can set the namespace

Tutorial Part One: Using the Generator

Step 1

You have to set your base settings.

Base Tag

The ‘Base Tag’ needs to be the same tag as the NPC you will generate in MCStacker later

Namespace

The functions that are generated need to belong to a ‘Namespace’ set this here.

Datapack Name

This is the name of the generated zip file

Description

¯\_(ツ)_/¯

Main Tick Tag

Checking this will make it so the main function loop runs every tick after the vanilla tick. If you don’t check this you have to run the main function from a repeating command block.

Distance

Distance is the range in blocks you have to be in order to interact with the NPC.

Text Color

This the text color of what the NPC says to the player.

Option Color

This is the text color of the options the NPC gives the player.

Step 2

In the green box labelled: Statement 1 (The first thing it says), Write some text like this:

I can do magic.\nWhat would you like me to do?

Step 3

Now add some options. Click the ‘Add Option’ button twice. In Option 1 set the following:

Option Text

Levitate You

Hover Text

This will apply the levitate effect to you

Next Statement

Finish Talking

Execute At

You do not need to modify this but you can if you need to for more complex NPC behaviors.

Now add the command by clicking the ‘Add Command’ button. Add this to the Command 1 field:

/effect give @p minecraft:levitation 5 2

In Option 2 set the following:

Option Text

Teleport You

Hover Text

You will teleport 5 blocks on each axis

Next Statement

Finish Talking

Execute At

You do not need to modify this but you can if you need to for more complex NPC behaviors.

Now add the command by clicking the ‘Add Command’ button . Add this to the Command 1 field:

/tp @p ~5 ~5 ~5

Step 4

Next you want the NPC to say something after it has levitated or teleported you. Do this by clicking ‘Add NPC Statement’. Write in the following:

Thanks for checking out my magic.

Click the ‘Add Option’ button in this section. In Option 1 set the following:

Option Text

Next

Next Statement

Statement 1

Execute At

You do not need to modify this but you can if you need to for more complex NPC behaviors.

Remember the first two options we added into the first statement. You need to change the Next Statement to ‘Statement 2’

That’s it. If your settings look like this, then your datapack is ready to download.

Become an MCStacker Patreon to make these ads disappear. Head over to patreon.com/mcstacker to get this month's ad-free link.

Tutorial Part Two: After You’ve Generated the Datapack

Step 1

Use the ‘Interactive NPC Generator’ to set up your NPCs dialog, options and commands just like in Part One of the Tutorial. Make sure you set the following base settings for this tutorial:

Base Tag

MyNPC

Namespace

npcgenerator

Datapack Name

MyDatapack

Step 2

Click the ‘Download Datapack’ button.

Step 3

You should see a file named MyDatapack.zip in your Downloads folder. Copy this to the datapack folder of your Minecraft world. For example: