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

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockComponentRegistry.registerCustomComponent("fm:pedestal", {
    onPlayerInteract(eventData) {
      const player = eventData.player;
      const block = eventData.block;
      const dimension = eventData.dimension
      const equippable = player?.getComponent("minecraft:equippable");
      const item = equippable.getEquipmentSlot(EquipmentSlot.Mainhand);

//off

    if (block.typeId === 'fm:pedestal_on') {

        system.run(() => {
         block.setType("fm:pedestal");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run function drop2`);
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run tp @e[family=c_auras,r=1] ~ ~-1000~`);
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:kill2 ~~-1000~`);

        });
      }
      
//items      

    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:thunder_search') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:thunder_spell_item ~~0.4~`);
        });}
      }
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:dark_blood_rune') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:dark_blood_rune_item ~~0.4~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:demonsalt') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:demon_salt_item ~~0.4~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:e_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_empty_aura3 ~~0.4~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:obsidian') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:obsdian_item ~~0.4~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:dark_parchment') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:dark_parch_item ~~0.4~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:magic_singularity') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:singularity_item ~~0.3~`);
        });}
      }
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:nether_star') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:nether_star_item ~~0.4~`);
        });}
      }
      
      
//25 items;-; Aaaaaaassssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      
    if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:light_blood_rune') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:light_blood_rune_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:glowstone') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:glowstone_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:light_parchment') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:light_parch_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:mandrake_item') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:mandragora_item ~~0.3~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:prismin_crystal_shards') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:prismin_crystal_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:brain') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:brain_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:earth_parchment') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:nature_parch_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:henbane_item') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:henbane_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:heart') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:heart_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:ritualistic_dagger') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:dagger_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:shield_search') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:shield_search_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:blood_botle') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:blood_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:end_crystal') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:ender_crystal_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:snowball') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:snowball_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'minecraft:fire_charge') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:fireball_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:l_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_light_aura2 ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:nature_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_nature_aura2 ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:fire_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_fire_aura2 ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:dark_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_dark_aura2 ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:cold_aura') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:item_cold_aura2 ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:fire_parchment') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:fire_parch_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:fire_rune') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:fire_rune_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:ice_rune') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:ice_rune_item ~~0.4~`);
        });}
      }
      if (block.typeId === 'fm:pedestal') {
         if (item.typeId === 'fm:ice_parchment') {
        system.run(() => {
         block.setType("fm:pedestal_on");
         block.dimension.playSound("mob.mana_gen_on", block.center());
         block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon fm:ice_parch_item ~~0.4~`);
        });}
      }
    }  
  });
});