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

world.afterEvents.itemUse.subscribe(async (event) => {
	const { itemStack, source } = event;
	const player = source;
	
	// Ore scanner use
	if (itemStack.typeId === "oct_plev:ore_scanner") {		
		player.runCommand('/summon oct_plev:ore_scanner_entity ~-5 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~-4 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~-3 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~-2 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~-1 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~0 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~1 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~2 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~3 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~4 ~-5 ~-5');
		player.runCommand('/summon oct_plev:ore_scanner_entity ~5 ~-5 ~-5');
		
		player.runCommand('/clear @s oct_plev:ore_scanner 0 1');
	}
});