import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui";

const ui = new ActionFormData()
    .title("Kamen Rider Battle Craft")
    .body(" ")
    .button("Mission", "textures/ui/mission")
    .button("Shop", "textures/ui/shop")
    .button("Exit", "textures/ui/exit");
    
world.afterEvents.itemUse.subscribe((event) => {
  const { source, itemStack } = event
  switch (itemStack.typeId) {
  	case "minecraft:compass": ui.show(source); break;
  }
});

world.beforeEvents.worldInitialize.subscribe(initEvent => {
    // first
    initEvent.itemComponentRegistry.registerCustomComponent('rider:henshin_onka_open', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_hibiki');
        }
    });
    
    // second
    initEvent.itemComponentRegistry.registerCustomComponent('rider:arcle_belt_stone', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_kuuga');
        }
    });
    
    // third
    initEvent.itemComponentRegistry.registerCustomComponent('rider:off', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function off');
        }
    });
    
    // fourth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:finish', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function set_finish');
        }
    });
    
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:seed_of_agito', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_agito');
        }
    });
    
    // sixth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:identifier_remove', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function remover');
        }
    });
    
    // seventh
    initEvent.itemComponentRegistry.registerCustomComponent('rider:deno_belt_hand', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function deno_belt');
        }
    });          
            
    // eighth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:pass', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function rider_pass');
        }
    });
    
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:choose_form', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function choose_form');
        }
    });
    
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ad:ryuki', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_ryuki');
        }
    });
    
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ad:ryuga', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_ryuga');
        }
    });
    
    // tenth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:faiz_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function faiz_driver');
        }
    });
    
    // eleven
    initEvent.itemComponentRegistry.registerCustomComponent('rider:faiz_phone', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function r_faiz_phone');
        }
    });
    
    // twelve
    initEvent.itemComponentRegistry.registerCustomComponent('rider:belt', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function rider_belt_kabuto');
        }
    });
    
    // thirdteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:kabuto_zecter', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function kabuto_zecter');
        }
    });
    
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:kivat', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function kivat');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('card:decade', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_decade');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:decadriver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function decadriver');
        }
    }); 
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('card:decade_violent_emotion', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_decade_violent_emotion');
        }
    }); 
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:disc_hibiki', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function finish_hibiki');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:ziku_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function ziku_driver');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:zio_ride_watch', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function zio_ride_watch');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:build_driver_hand', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function build_driver');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('fb:rabbit', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function fb_rabbit');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('fb:tank', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function fb_tank');
        }
    });
        // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('card:hopper1', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function hopper1');
        }
    });
    // seventh
    initEvent.itemComponentRegistry.registerCustomComponent('card:stream_liner', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function stream_liner');
        }
    });          
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:gotchard_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function gotchard_driver');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:zero_one_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function zero_one_driver');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('prorise_key:rising_hopper', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function pk_rising_hopper');
        }
    });  
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:ooo_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function ooo_driver');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('medal:taka', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function medal_taka');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('medal:tora', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function medal_tora');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('medal:batta', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function medal_batta');
        }
    });
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('ad:knight', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_knight');
        }
    });    
    // fiveteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:w_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function w_driver');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('memory:joker', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('playsound joker @a[x=~,y=~,z=~,r=5]');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('memory:cyclone', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('playsound cyclone @a[x=~,y=~,z=~,r=5]');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('ring:driver_on', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function ring_driver_on');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:wizard_driver_armor_locked', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function wizard_driver_armor');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:gamer_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function gamer_driver');
        }
    });
      // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:revice_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function revice_driver');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:rex_vistamp', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function rex_vistamp');
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('gashat:mighty_action_x', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function mighty_action_x_gashat');
        }
    });
    // fifth
  initEvent.itemComponentRegistry.registerCustomComponent("rider:card_put_out", {
    onUse: ({ source, itemStack }) => {
      const commands = [
        "function card_1",
        "function card_2",
        "function card_3",
        "function card_4",
        "function card_5",
      ];

      const randomIndex = Math.floor(Math.random() * commands.length);
      const selectedCommand = commands[randomIndex];

      source.runCommandAsync(selectedCommand)
        }
    });
    // fifth
  initEvent.itemComponentRegistry.registerCustomComponent("rider:ultimate_access", {
    onUse: ({ source, itemStack }) => {
      const commands = [
        "say unsuccessful",
        "say unsuccessful",
        "say unsuccessful",
        "say unsuccessful",
        "function kuuga_ultimate",
      ];

      const randomIndex = Math.floor(Math.random() * commands.length);
      const selectedCommand = commands[randomIndex];

      source.runCommandAsync(selectedCommand)
        }
    });
    // fifth
    initEvent.itemComponentRegistry.registerCustomComponent('card:decade_final_attack', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function decade_final_attack');
        }
    }); 
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ad:ouja', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_ouja');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:faiz_pointer', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function faiz_pointer');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:fourze_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function fourze_driver');
        }
    });
    // eighth
    initEvent.itemComponentRegistry.registerCustomComponent('gochizo:poppin_gummy', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function g_poppin_gummy');
        }
    });
    // third
    initEvent.itemComponentRegistry.registerCustomComponent('rider:gavv_henshin_belt', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function gavv_belt');
        }
    });
    // fourteen
    initEvent.itemComponentRegistry.registerCustomComponent('rider:spin', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function spin');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ad:zolda', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_zolda');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ad:raia', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function henshin_raia');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:red_king_stone', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function red_king_stone');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:sengoku_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function sengoku_driver');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('ls:orange', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function orange');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:ghost_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function ghost_driver');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('eyecon:ore_ghost', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function eyecon');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('card:shield_vent', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function guard_vent');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:dragclaw', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function dragclaw');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('card:sword_vent', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function dragsaber');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('card:strike_vent', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function strike_vent');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:drive_turn', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function drive_turn');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:drive_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function drive_driver');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('shift:speed', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function speed');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:zeztz_driver', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function zeztz_driver');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('capsem:impact', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function capsem_impact');
        }
    });
    // nineth
    initEvent.itemComponentRegistry.registerCustomComponent('rider:zeztz_set', {
        onUse: ({ source, itemStack }) => {
            source.runCommandAsync('function zeztz_set');
        }
    });
});