import { runInterval, test, fetchAllEntities } from "./Eternal/Utils";

const entTable = [
  {
    typeId: "eternal:pixie",
    name: "Pixie",
  },
  {
    typeId: "eternal:fawk",
    name: "Fawk",
  },
  {
    typeId: "eternal:pipbird",
    name: "Pipbird",
  },
  {
    typeId: "eternal:golden_dragon",
    name: "Golden Dragon",
  },
];

runInterval(async () => {
  const selectors = [];
  for (const ent of entTable) selectors.push(`@e[type=${ent.typeId}]`);
  const entities = fetchAllEntities(selectors);
  for (const entity of entities) {
    if (entity.isTamed && entity.nameTag === "") {
      const ent = entTable.find((entt) => entt.typeId === entity.typeId);
      if (ent) entity.nameTag = ent.name;
    }
  }
});
