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

{ import("@minecraft/server").BlockCustomComponent }
export const event_mimic = {
  onPlayerDestroy: (e, summonVariant) => {
    // Make sure that the event has the necessary information
    // Asegurarse de que el evento tiene la información necesaria
    if (!e.player || !e.block) return;

    // Verify if the player is in survival mode
    // Verificar si el jugador está en modo supervivencia
    if (e.player.getGameMode() !== "survival") return;

    // Obtain the tool that the player has in the main hand.
    // Obtener la herramienta que el jugador tiene en la mano principal
    const equip = e.player.getComponent(EntityEquippableComponent.componentId);
    if (!equip) return;

    const mainhand = equip.getEquipment(EquipmentSlot.Mainhand);

    // Execute action if no tool is in hand
    // Ejecutar acción si no hay herramienta en la mano
    if (!mainhand) {
      executeRandomAction(e.block.location, e.block.dimension, summonVariant);
      return;
    }

    // Check if the object has the component 'enchantable'
    // Verificar si el objeto tiene el componente 'enchantable'
    const enchantable = mainhand.getComponent("enchantable");
    if (!enchantable) {
      executeRandomAction(e.block.location, e.block.dimension, summonVariant);
      return;
    }

    // Check if you have the Silk Touch enchantment
    // Revisar si tiene el encantamiento Silk Touch
    const silkTouch = enchantable.getEnchantment("silk_touch");

    // Execute action if you do NOT have Silk Touch
    // Ejecutar acción si NO tiene Silk Touch
    if (!silkTouch) {
      executeRandomAction(e.block.location, e.block.dimension, summonVariant);
    }
  },
};

// Function to execute a random action
// Función para ejecutar una acción aleatoria
function executeRandomAction(location, dimension, summonVariant) {
  const randomChoice = Math.random(); // Número aleatorio entre 0 y 1
  if (randomChoice < 0.5) {
    const summonCommand = `summon otherworldly_winter:mimic ${location.x} ${location.y} ${location.z} facing @r minecraft:make_${summonVariant}`;
    dimension.runCommandAsync(summonCommand);
  } else {
    const lootCommand = `loot spawn ${location.x} ${location.y} ${location.z} loot "entities/mimic"`;
    dimension.runCommandAsync(lootCommand);
  }
};

// Specific events reusing generic logic
// Eventos específicos reutilizando la lógica genérica
export const event_mimic1 = {
  onPlayerDestroy: (e) => event_mimic.onPlayerDestroy(e, "variant1"),
};

export const event_mimic2 = {
  onPlayerDestroy: (e) => event_mimic.onPlayerDestroy(e, "variant2"),
};
export const event_mimic3 = {
  onPlayerDestroy: (e) => event_mimic.onPlayerDestroy(e, "variant3"),
};
export const event_mimic4 = {
  onPlayerDestroy: (e) => event_mimic.onPlayerDestroy(e, "variant4"),
};
export const event_mimic5 = {
  onPlayerDestroy: (e) => event_mimic.onPlayerDestroy(e, "variant5"),
};

export const event_deepslate = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'dungeon:wooden_pickaxe' || item?.typeId === 'minecraft:gold_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const silk_touch = item.getComponent('enchantable').getEnchantment('silk_touch')
        if (!silk_touch) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/deep_stone"`);
          }
        }
        if (silk_touch) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/silk_deep_stone"`);
          }
        }
      }
    }
  },
};
export const event_stone = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:wooden_pickaxe' || item?.typeId === 'minecraft:gold_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const silk_touch = item.getComponent('enchantable').getEnchantment('silk_touch')
        if (!silk_touch) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/stone"`);
          }
        }
        if (silk_touch) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/silk_stone"`);
          }
        }
      }
    }
  },
};
export const event_glimmerite = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'minecraft:glimmerite_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/glimmerite_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/glimmerite_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/glimmerite_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/glimmerite_ore"`);
          }
        }
      }
    }
  },
};
export const event_viritum = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/viritum_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/viritum_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/viritum_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/viritum_ore"`);
          }
        }
      }
    }
  },
};
export const event_iron = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/iron_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/iron_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/iron_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/iron_ore"`);
          }
        }
      }
    }
  },
};
export const event_coal = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:wooden_pickaxe' || item?.typeId === 'minecraft:gold_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/coal_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/coal_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/coal_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/coal_ore"`);
          }
        }
      }
    }
  },
};
export const event_gold = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/gold_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/gold_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/gold_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/gold_ore"`);
          }
        }
      }
    }
  },
};
export const event_copper = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/copper_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/copper_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/copper_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/copper_ore"`);
          }
        }
      }
    }
  },
};
export const event_vitalife = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/vitalife_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/vitalife_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/vitalife_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/vitalife_ore"`);
          }
        }
      }
    }
  },
};
export const event_diamond = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/diamond_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/diamond_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/diamond_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/diamond_ore"`);
          }
        }
      }
    }
  },
};
export const event_lapis = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/lapis_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/lapis_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/lapis_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/lapis_ore"`);
          }
        }
      }
    }
  },
};
export const event_emerald = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/emerald3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/emerald2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/emerald1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/emerald"`);
          }
        }
      }
    }
  },
};
export const event_jade = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/jade3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/jade2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/jade1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/jade"`);
          }
        }
      }
    }
  },
};
export const event_tungsten = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/tungsten3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/tungsten2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/tungsten1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/tungsten_ore"`);
          }
        }
      }
    }
  },
};
export const event_titanium = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/titanium3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/titanium2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/titanium1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/titanium_ore"`);
          }
        }
      }
    }
  },
};
export const event_silver = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'dungeon:wooden_pickaxe' || item?.typeId === 'minecraft:gold_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/silver_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/silver_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/silver_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/silver_ore"`);
          }
        }
      }
    }
  },
};
export const event_cobalt = {
  onPlayerDestroy: e => {
    let players = world.getPlayers();
    for (let player of players) {
      const item = player.getComponent('inventory').container.getItem(e.player.selectedSlotIndex);
      if (e.player.getGameMode() == 'survival' && item?.typeId === 'minecraft:stone_pickaxe' || item?.typeId === 'minecraft:gold_pickaxe' || item?.typeId === 'minecraft:iron_pickaxe' || item?.typeId === 'minecraft:diamond_pickaxe' || item?.typeId === 'dungeon:cobalt_hammer' || item?.typeId === 'minecraft:netherite_pickaxe' || item?.typeId === 'dungeon:silvirum_pickaxe' || item?.typeId === 'dungeon:glimmerite_pickaxe' || item?.typeId === 'dungeon:glimmerite_hammer' || item?.typeId === 'dungeon:silvirum_pickaxe') {
        const fortune = item.getComponent('enchantable').getEnchantment('fortune')
        const fortuneLevel = fortune?.level
        if (fortuneLevel == 3) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/cobal_ore3"`);
          }
        }
        if (fortuneLevel == 2) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/cobal_ore2"`);
          }
        }
        if (fortuneLevel == 1) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/fortune/cobal_ore1"`);
          }
        }
        if (fortuneLevel == 0 || !fortune) {
          if (e.player.getGameMode() == 'survival') {
            e.block.dimension.runCommandAsync(`loot spawn ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} loot "blocks/cobalt_ore"`);
          }
        }
      }
    }
  },
};