import { world, system } from "@minecraft/server";

world.beforeEvents.itemUse.subscribe((data) => {
  let player = data.source;
  if (data.itemStack.typeId == "txd_pirate1:pirate_hat")
    system.run(() => find_parrot(player));
  if (data.itemStack.typeId == "txd_pirate1:right_eye_patch")
    system.run(() => find_parrot(player));
  if (data.itemStack.typeId == "txd_pirate1:left_eye_patch")
    system.run(() => find_parrot(player));
  if (data.itemStack.typeId == "txd_pirate1:captain_coat")
    system.run(() => find_parrot(player));
  if (data.itemStack.typeId == "txd_pirate1:pirate_bandana")
    system.run(() => find_parrot(player));
  
  function find_parrot() {
    player.runCommand("function tomaxed/pirate1/txd_findparrot");
  }
});