2

Set up NPC's for your friends to talk to!

ShelLuser's Avatar ShelLuser1/6/24 3:01 pm
2 emeralds 131 2
1/25/2024 4:48 am
Mishi_Mikaela's Avatar Mishi_Mikaela
Hi gang!


scared_villager
He actually looks scared, right? ;)


While you may notice that we're playing on a modded server please trust me when I tell you guys that all you need to make this happen is a mere datapack, vanilla too!

So what is happening here? Well... I got a little carried away when messing with my command blocks and ended up creating a really tough son of a b... bomby ;) Think I'm kidding? ;)


pure evil ;)

Son of a gun! ;)



Fun fact: the fire effect you see in the screenshot above is courtesy of the HasVisualFire entity property, this allows you to set up an entity with fire without causing them any actual damage. Yah, this isn't my idea: the server Aya and me used to play on (cough, Empire Minecraft, cough) used this mechanic long before it become it became mainstream. And the last time I set up an enraged entity I had to mess with potion effects to negate the flames.

But yah, I put some time & effort into this custom mob so I set it up with the "PersistenceRequired" flag; in other words, it can't despawn. It also moves 2.5x faster than a regular zombie and causes more damage. So after it ran off I figured I'd better try and warn my friend Aya in some kind of casual way, see above to see how that worked out ;)

So how to make those NPC's talk?

First... the NoAI property: set this to true in order to make sure that a spawned entity ("mob") doesn't really do anything, this is why the scared villager kept waiting in the corner waiting for Aya to try and 'use' it. This leads up to the next issue: how to make it interact? Well... the secret is that the mob doesn't interact, instead it's merely the player who does which triggers the result. You catch this using a so called advancement:

advancements

See what I mean?

As soon as a player interacts with a villager which has a tag called "messenger" then the 'server:story/the_message' function fires up. That function simply makes the NPC talk by using a 'say' command. However, the real important part is the /advancement revoke part which makes sure that as soon as the player interacts with the villager again then the mob keeps talking back.

Resulting in what you saw above ;)

Yah... Minecraft has come a long way I think because at some time things like these were only possible using mods, and see where we are now! And the secret behind it? Well, easy: advancements, as well as datapacks.

I'm actually considering to 'revisit' those blogs but we'll see how well that goes.

But for now... I hope you can agree that this is one heck of a vanilla mechanic.
Posted by ShelLuser's Avatar
ShelLuser
Level 57 : Grandmaster Engineer
89

Create an account or sign in to comment.

2

1
01/25/2024 4:48 am
Level 1 : New Network
Mishi_Mikaela
Mishi_Mikaela's Avatar
Man, I remember working on an adventure map! Back then, there was a demand for it, and creating NPC dialogues was such a pain with long command blocks and redstone. Clickable text was the new thing back then, with branching stories and extensive dialogues between the player and NPC. It's such a shame that I never finished it. I wonder if I can find it.
1
01/06/2024 4:37 pm
Level 36 : Artisan Miner
ScotsMiser
ScotsMiser's Avatar
Nice tip for the site's mapmakers (and similar) 🥂
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome