import { world, EquipmentSlot } from "@minecraft/server";
/* 
Checks which item is in the mainhand
Adds effect if a specific item like a sword/spear is in the mainhand
*/

export function guideBook(player) {
  const typeId = player.typeId;
  if (typeId !== "minecraft:player") return;

  const mainHand = player.getComponent("equippable")?.getEquipment(EquipmentSlot.Mainhand);
  if (!mainHand) return;

  // // return in order to display enforced_vindicator_chestplate health display
  // const chestplate = player.getComponent("equippable")?.getEquipment(EquipmentSlot.Chest);
  // if (chestplate && chestplate.typeId === "hb_hr:enforced_vindicator_chestplate") return;
  switch (mainHand.typeId) {
    case "hb_hr:guide_book_spawn_egg":
      player.runCommand('/titleraw @s actionbar {"rawtext":[{"translate":"hb_hr.guide_book.actionbar_hint"}]}');
      break;
    default:
      break;
  }
}
