• Hey! Register here to create your account, engage with the community, and talk about what is new!

execute code when a certain entity is right clicked.

Diceey

New member
Joined
Sep 20, 2021
Messages
15
Reaction score
0
How can I make it when a certain entity like a villager is right clicked it executes code but if a player right clicks a different villager it executes different code.
 
Solution
1632183240508.png


Hey! In order to do this, use the ClickEntity player event, and then use the if entity -> NameEquals, and then place a text inside the chest. After the piston (or bracket), place what you would like to happen.

1632183399937.png

In this example, the code runs like the following:

If name equals "NotBob" {
Send message to villager
}

If name equals "Bob" {
We decide to kick the player because Bob isn't nice
}

Refrizor

Retired Administrator
Retired Admin
Joined
Aug 16, 2020
Messages
513
Reaction score
362
1632183240508.png


Hey! In order to do this, use the ClickEntity player event, and then use the if entity -> NameEquals, and then place a text inside the chest. After the piston (or bracket), place what you would like to happen.

1632183399937.png

In this example, the code runs like the following:

If name equals "NotBob" {
Send message to villager
}

If name equals "Bob" {
We decide to kick the player because Bob isn't nice
}
 
Solution
Top Bottom