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

world.afterEvents.itemUse.subscribe((data) => {

 const player = data.source;
 const item = data.itemStack;
 const itemCD = item.getComponent("minecraft:cooldown");
 const cooldown = itemCD?.getCooldownTicksRemaining(player);

 if (cooldown >= 0.1) {
    return;
}

 switch (item.typeId) {
 case 
 'gojidraw:wardenzilla_axe':
    player.runCommand(            "playsound entity.golem_kong.axe_slam @a [r=50]");
    player.runCommand(            "function axe_attack");
    itemCD.startCooldown(player);
      break;
      
 case 
 'gojidraw:emp_hammer':
    player.runCommand(            "playsound entity.ender_muto.emp_smash @a [r=50]");
    player.runCommand(            "summon gojidraw:player_emp_attack");
    itemCD.startCooldown(player);
      break;
      
 case 
 'gojidraw:blazing_eye':
    player.runCommand(            "summon player_blazing_neakri:flame_ball_c");
    itemCD.startCooldown(player);
      break;
      
 case 
 'gojidraw:endless_stone_item':
    player.runCommand(            "playsound entity.titan.stomp3 @a [r=50]");
    player.runCommand(            "summon gojidraw:jump_stone");
    player.runCommand(            "effect @a[r=3] levitation 1 14 true");
    player.runCommand(            "effect @a[r=3] slow_falling 3 1 true");
    itemCD.startCooldown(player);
      break;
      
 case 
 'gojidraw:kaiju_blessing':
    player.runCommand(            "effect @a[r=3] resistance 50 255 true");
    player.runCommand(            "effect @a[r=3] strength 50 4 true");
    player.runCommand(            "playsound beacon.power @a [r=5]");
    player.runCommand(            "particle mothlley:light_effect3");
    itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mecha_wardenzilla_attack':
      player.runCommand( "event entity @e[family=kaiju_mecha_wardenzilla_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mecha_wardenzilla_charge_attack':
      player.runCommand( "event entity @e[family=kaiju_mecha_wardenzilla_control,c=1] goji:charged_attack");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mecha_wardenzilla_roar':
      player.runCommand( "event entity @e[family=kaiju_mecha_wardenzilla_control,c=1] minecraft:sonic_roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:ender_muto_fly':
      player.runCommand( "event entity @e[family=kaiju_ender_muto_control,c=1] goji:flying");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:ender_muto_not_fly':
      player.runCommand( "event entity @e[family=kaiju_ender_muto_control,c=1] goji:not_flying");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:ender_muto_attack':
      player.runCommand( "event entity @e[family=kaiju_ender_muto_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:ender_muto_special_ability':
      player.runCommand( "effect @e[family=kaiju_ender_muto_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_ender_muto_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:ender_muto_roar':
      player.runCommand( "event entity @e[family=kaiju_ender_muto_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:squcylla_attack':
      player.runCommand( "event entity @e[family=kaiju_squcylla_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:squcylla_roar':
      player.runCommand( "event entity @e[family=kaiju_squcylla_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:squcylla_special_ability':
      player.runCommand( "effect @e[family=kaiju_squcylla_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_squcylla_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:blazing_neakri_attack':
      player.runCommand( "event entity @e[family=kaiju_blazing_neakri_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:blazing_neakri_roar':
      player.runCommand( "event entity @e[family=kaiju_blazing_neakri_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:blazing_neakri_special_ability':
      player.runCommand( "effect @e[family=kaiju_blazing_neakri_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_blazing_neakri_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wither_ghidorah_attack':
      player.runCommand( "event entity @e[family=kaiju_wither_ghidorah_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wither_ghidorah_roar':
      player.runCommand( "event entity @e[family=kaiju_wither_ghidorah_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wither_ghidorah_special_ability':
      player.runCommand( "effect @e[family=kaiju_wither_ghidorah_control,c=1] instant_health 2 5 true");
      player.runCommand( "playanimation @e[family=kaiju_wither_ghidorah_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:behemoohoglin_attack':
      player.runCommand( "event entity @e[family=kaiju_behemoohoglin_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:behemoohoglin_roar':
      player.runCommand( "event entity @e[family=kaiju_behemoohoglin_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:behemoohoglin_special_ability':
      player.runCommand( "effect @e[family=kaiju_behemoohoglin_control,c=1] regeneration 2 255 true");
      player.runCommand( "playanimation @e[family=kaiju_behemoohoglin_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:behemoohoglin_charge_attack':
      player.runCommand( "event entity @e[family=kaiju_behemoohoglin_control,c=1] goji:run_event");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:sniffelah_attack':
      player.runCommand( "event entity @e[family=kaiju_sniffela_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:sniffelah_roar':
      player.runCommand( "event entity @e[family=kaiju_sniffela_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:sniffelah_special_ability':
      player.runCommand( "effect @e[family=kaiju_sniffela_control,c=1] regeneration 2 255 true");
      player.runCommand( "playanimation @e[family=kaiju_sniffela_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wardenzilla_attack':
      player.runCommand( "event entity @e[family=kaiju_wardenzilla_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mothlley_attack':
      player.runCommand( "event entity @e[family=kaiju_mothlley_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mothlley_roar':
      player.runCommand( "event entity @e[family=kaiju_mothlley_control,c=1] goji:godray_attack");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:mothlley_special_ability':
      player.runCommand( "effect @e[family=kaiju_mothlley_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_mothlley_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:rophantom_attack':
      player.runCommand( "event entity @e[family=kaiju_rophantom_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:rophantom_charge_attack':
      player.runCommand( "event entity @e[family=kaiju_rophantom_control,c=1] goji:spin_attack");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:rophantom_special_ability':
      player.runCommand( "effect @e[family=kaiju_rophantom_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_rophantom_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:golem_kong_attack':
      player.runCommand( "event entity @e[family=kaiju_golem_kong_control,c=1] minecraft:start_melee_mode");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:golem_kong_special_ability':
      player.runCommand( "effect @e[family=kaiju_golem_kong_control,c=1] regeneration 3 255 true");
      player.runCommand( "playanimation @e[family=kaiju_golem_kong_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:golem_kong_roar':
      player.runCommand( "event entity @e[family=kaiju_golem_kong_control,c=1] minecraft:roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wardenzilla_roar':
      player.runCommand( "event entity @e[family=kaiju_wardenzilla_control,c=1] minecraft:sonic_roar");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojic:wardenzilla_special_ability':
      player.runCommand( "effect @e[family=kaiju_wardenzilla_control,c=1] instant_health 2 3 true");
      player.runCommand( "playanimation @e[family=kaiju_wardenzilla_control,c=1] animation.sculk_zilla.healing");
      itemCD.startCooldown(player);
      break;
      
 case 
 'gojidraw:phantom_totem':
    player.runCommand(            "summon gojidraw:rophantom_soul");
    player.runCommand(            "playsound beacon.power @a [r=5]");
    itemCD.startCooldown(player);
      break;
      
    }
});