#clickable villager npc
1 messages · Page 1 of 1 (latest)
What do u wanna do? Do u wanna use form-ui?
@blazing dawn yes
I think you have 2 ways:
- full scripting: you detect when a player is close to the npc, if so you get player’s view vettore and listen to itemuse event... if on itemuse the player’s view vettore intersecate e npc’s location, then you open the ui.
- entities, I think you may be able to edit the villager.json entity file so to run a script event on interaction, which you catch in your script and open the ui. This way (if possible) is surely more efficient of the other.
For the full script, can u show me the code pls
No sry, I’m not going to write that for you. I wrote the steps. If you want a suggestion check the Vector class. I saw that it includes a lot of useful manipulations of vector, and you are probably not gonna need self implement anything (that would require some math).
world.afterEvents.entityHit.subscribe((event) => {
const player = event.entity, hit = event.hitEntity;
if (!hit)
return;
if (!player || !(player instanceof Player))
return;
if (hit.typeId !== 'Changetoyourentity')
return;
Form(player);
});```
Ye, this is a possible approach, altho it will work with hits, instead of right-clicks
have you already edited your entities' interact component?