For 1.13-1.17 Minecraft Java Edition
RPG Villagers
In this tutorial, I will be showing you how to have click events with villagers and conversations with them etc using scoreboard objectives. If you are here for the commands rather than learning they are all at the bottom of the page.
The commands I will be using to achieve this are:
• Scoreboard
• Execute
• Tell
• Summon
Method / Explanation:
In this tutorial I will create various villagers with different events when you click on them. Firstly we are going to have a universal scoreboard for all of our Villagers for when we click them.
The commands I will be using to achieve this are:
• Scoreboard
• Execute
• Tell
• Summon
Method / Explanation:
In this tutorial I will create various villagers with different events when you click on them. Firstly we are going to have a universal scoreboard for all of our Villagers for when we click them.
Now if you set the scoreboard to the sidebar (Just for testing)
/scoreboard objectives setdisplay sidebar VillagerClick
You will see it go up every time you right click on a villager. Next if we want a conversation or an event when we click on the villager we don't want it to open the trade menu. We can remove this by giving it an empty Offers data tag '{Offers:{}}'
/scoreboard objectives setdisplay sidebar VillagerClick
You will see it go up every time you right click on a villager. Next if we want a conversation or an event when we click on the villager we don't want it to open the trade menu. We can remove this by giving it an empty Offers data tag '{Offers:{}}'
I gave it NoAI:1 so it wouldn't move, if you are doing the same, you can change where it is facing with the tp command.
/execute as @e[name=Dan] at @s run tp @s ~ ~ ~ ~LEFT/RIGHT ~UP/DOWN
Then we need to give it a name, I am going to call my first example Dan. In this example I am just going to make it say the same message every time you click on him.
To do this we are going to execute from Dan and then tell all people who have a score of at least one in the radius of five to him a message:
/execute at @e[type=minecraft:villager,name=Dan] run tell @a[scores={VillagerClick=1},distance=..5,sort=nearest] Hello, Welcome to the forest!
The tell command is like a combination of say and tell raw, you can not choose colors or formatting but you can choose who sees it. You can use /say or /tellraw instead if you want too.
Then we will have a scoreboard command reseting all peoples 'VillagerClick' score so it doesn't spam them:
/scoreboard players set @a VillagerClick 0
Now for our next example we are going to create a new villager called Steve. This one is also going to have an arrow summon above the player. You can have any command you want:
/execute at @e[type=minecraft:villager,name=Steve] at @a[scores={VillagerClick=1},distance=..5,sort=nearest] run summon Arrow ~ ~3 ~
Note you can add as many commands or villagers as you want just make sure your villager click reseter is ALWAYS at the very end.
/execute as @e[name=Dan] at @s run tp @s ~ ~ ~ ~LEFT/RIGHT ~UP/DOWN
Then we need to give it a name, I am going to call my first example Dan. In this example I am just going to make it say the same message every time you click on him.
To do this we are going to execute from Dan and then tell all people who have a score of at least one in the radius of five to him a message:
/execute at @e[type=minecraft:villager,name=Dan] run tell @a[scores={VillagerClick=1},distance=..5,sort=nearest] Hello, Welcome to the forest!
The tell command is like a combination of say and tell raw, you can not choose colors or formatting but you can choose who sees it. You can use /say or /tellraw instead if you want too.
Then we will have a scoreboard command reseting all peoples 'VillagerClick' score so it doesn't spam them:
/scoreboard players set @a VillagerClick 0
Now for our next example we are going to create a new villager called Steve. This one is also going to have an arrow summon above the player. You can have any command you want:
/execute at @e[type=minecraft:villager,name=Steve] at @a[scores={VillagerClick=1},distance=..5,sort=nearest] run summon Arrow ~ ~3 ~
Note you can add as many commands or villagers as you want just make sure your villager click reseter is ALWAYS at the very end.
I recommend watching the video to help visualize these examples.
Now for our final villager we will create a conversation. I am going to create another villager named Paul. This one is a bit more complicated and will require another scoreboard objective.
/scoreboard objectives add PaulScore dummy
When creating conversations, you will need a new scoreboard objective for every villager so say you had one called Simon create an objective called 'SimonScore'
This objective will act as a variable to store our progress in the conversation. For conversations, the command you want to execute when they click on it is
/execute at @e[type=minecraft:villager,name=Paul] run scoreboard players add @e[scores={VillagerClick=1},distance=..5] PaulScore 1
In order to raise their PaulScore too.
Then for every part of the conversation we can add a /tell message
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=1},distance=..5,sort=nearest] Hello
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=2},distance=..5,sort=nearest] How Are You?
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=3..},distance=..5,sort=nearest] Ok Byee!
Note that for the last message in the conversation you have a minimum score but not an exact so if they try talk to the villager after the conversation has ended it will repeat it's last message rather than doing nothing.
If you ever need to reset the 'PaulScore' or whatever you named yours do (/scoreboard players reset @a PaulScore)
Remember all the commands are below if you want to double check them and if you are still confused you could watch the video. And if after that your still ever confused about something be sure to leave a comment on one of my videos :) ~Blue
Now for our final villager we will create a conversation. I am going to create another villager named Paul. This one is a bit more complicated and will require another scoreboard objective.
/scoreboard objectives add PaulScore dummy
When creating conversations, you will need a new scoreboard objective for every villager so say you had one called Simon create an objective called 'SimonScore'
This objective will act as a variable to store our progress in the conversation. For conversations, the command you want to execute when they click on it is
/execute at @e[type=minecraft:villager,name=Paul] run scoreboard players add @e[scores={VillagerClick=1},distance=..5] PaulScore 1
In order to raise their PaulScore too.
Then for every part of the conversation we can add a /tell message
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=1},distance=..5,sort=nearest] Hello
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=2},distance=..5,sort=nearest] How Are You?
/execute at @e[type=minecraft:villager,name=Paul] run tell @a[scores={VillagerClick=1,PaulScore=3..},distance=..5,sort=nearest] Ok Byee!
Note that for the last message in the conversation you have a minimum score but not an exact so if they try talk to the villager after the conversation has ended it will repeat it's last message rather than doing nothing.
If you ever need to reset the 'PaulScore' or whatever you named yours do (/scoreboard players reset @a PaulScore)
Remember all the commands are below if you want to double check them and if you are still confused you could watch the video. And if after that your still ever confused about something be sure to leave a comment on one of my videos :) ~Blue
Commands: