import { EntityInventoryComponent } from "@minecraft/server";

export const ITEM_LORES = {
  "mythicus_ws:waystone.andesite": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.blackstone": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.brickstone": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.end": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.sandstone": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.stone": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.allay": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.candles": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.creeper": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.easter_egg": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.end_crystal": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.horse": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.trident": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.villager": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.warden": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.energize.waystone": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.guidebook": [
    "§9§oWarpstone Add-On",
  ],
  "mythicus_ws:waystone.interact": [
    "§9§oWarpstone Add-On",
  ]

};

export function itemLore(player) {
  const inventory = player.getComponent(EntityInventoryComponent.componentId);
  if (!(inventory instanceof EntityInventoryComponent)) {
    return;
  }
  for (let i = 0; i < inventory.container.size; i++) {
    const item = inventory.container.getItem(i);
    if (!item || item.getLore().length) {
      continue;
    }
    const lore = ITEM_LORES[item.typeId];
    if (lore) {
      item.setLore(["", ...lore]);
      inventory.container.setItem(i, item);
    }
  }
}
