#cancel trade

1 messages · Page 1 of 1 (latest)

unique minnow
#

hello i got an item that transform a villager into a custom entity with a script but when i right click on it, the trade menu open and stop the transformation of the villager, do there is a way to cancel the trade menu to open and directly transform the villager?

unique minnow
tired wedge
#
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
    const {player, target, itemstack: item} = event;
    // detect when player interact with villager
    if (target.typeId === "minecraft:villager" || target.typeId === "minecraft:villager_v2") {
        // cancel trade
        event.cancel = true;
    }
});