[question] how to cancel a event that interacts with entity
TRLWeiss opened this issue ยท 2 comments
I would like to cancel the event that interact with the npc and open a gui.
Even though i have read the documantion but have no idea on how to use the zenscripts to complete it.
Hope there are any example for us newbie to better understand the crafttweaker.
You have to find the appropiated Event (https://docs.blamejared.com/1.12/en/Vanilla/Events/Events/PlayerInteractEntity/) and then do the following:
import crafttweaker.event.PlayerInteractEntityEvent
events.onPlayerInteractEntity(
function(event as PlayerInteractEntityEvent) {
//Look out for the ZenGetters & Zensetters
if(event.target.displayName == "Villager") {
event.cancel();
}
}
)
Any methods from extended or implemented classes like IEventCancelable (https://docs.blamejared.com/1.12/en/Vanilla/Events/Events/IEventCancelable/) can be used. Just the functionality on implementation changes (doesn't matter for you).