#How can i close a NPC UI?

1 messages · Page 1 of 1 (latest)

shrewd kraken
#

How can i close the NPC UI? event.cancel = true doesn't work

    if (!customUi) event.cancel = true;
    const { player, target } = event;
    if (target?.typeId === "minecraft:npc") {
        const res = await customUi.show(player);
        }
    })
rose junco
#

why not use a different entity?

#

you cant cancel an afterevent function only beforevents

pearl dome
#
world.beforeEvents.playerInteractWithEntity.subscribe((ev, { target, player, itemStack }) => {
  if (target.typeId === 'minecraft:npc') {
    ev.cancel = true;
  }
});```