#clickable villager npc

1 messages · Page 1 of 1 (latest)

teal lion
#

(right click) how would i make

blazing dawn
#

What do u wanna do? Do u wanna use form-ui?

odd breach
#

@blazing dawn yes

blazing dawn
# odd breach <@884180976278851655> yes

I think you have 2 ways:

  1. 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.
  2. 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.
odd breach
#

For the full script, can u show me the code pls

blazing dawn
#

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).

mossy pawn
#
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);
});```
blazing dawn
#

Ye, this is a possible approach, altho it will work with hits, instead of right-clicks

odd breach
#

@blazing dawn

#

For the second step

#

How do u use scriptevent on interaction

lament elk
odd breach
#

No and idk how to

#

Im a noob at this sry