
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:ability_cycle_empathic')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty("cycle_score", "string", "Heroes.Power.Icon", "Determins max energy for the power and what the math will be based on")
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
					const cycle_score = entry.getPropertyByName('cycle_score');
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add " + cycle_score + " dummy");
                    let scoreboard = Utils.server.scoreboard;
					let scoreboard_obj = scoreboard.getObjective(entry.getPropertyByName("cycle_score"));
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					let power_max = global.power_amount;
					if (containsTag(entity.getTags().toArray(), 'Heroes.Empathic.Next')) {
						value += 1;
						if (value > power_max) {
							value = - 2;
						}
					for (let power_list = value; power_list < power_max +2; power_list++) {
						let power = global['ability_' + power_list];
							if (power == 'Intuitive_Aptitude' && !containsTag(entity.getTags().toArray(), 'Heroes.Intuitive.Learned')) {
								power_list += 1;
								continue;
							}
						if (power_list > power_max) {
						power_list = -2; 
						continue;
							}
						if (power_list == -1) {
						entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " " + power_list + "");
						entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Next");
						break;
						}
						let power_cap = global['ability_' + power_list];
						if (power != 'Absorption' && power != 'Transferal' && power != 'Interplay' && power != 'Empathic_Mimicry') {
						entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add Powers." + power_cap + " dummy");
							let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_cap);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
					if (value_temp == 1 && abilityUtil.isEnabled(entity, 'heroes:empathic_mimicry', 'ability_call')) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " " + power_list + "");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Next");
					break;
								}
					if (value_temp == 2 && abilityUtil.isEnabled(entity, 'heroes:empathic_mimicry', 'ability_uncall')) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " " + power_list + "");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Next");
					break;
								}
							}
						}
						}
					}
						
						if (containsTag(entity.getTags().toArray(), 'Heroes.Empathic.Prev')) {
							value -= 1;
					let power_max = global.power_amount;
					for (let power_list = value; power_list > -3; power_list--) {
						let power = global['ability_' + power_list];
							if (power == 'Intuitive_Aptitude' && !containsTag(entity.getTags().toArray(), 'Heroes.Intuitive.Learned')) {
								power_list -= 1;
								continue;
							}
						if (power_list < -1) {
						power_list = power_max + 1; 
						continue;
							}
						let power_cap = global['ability_' + power_list];

						if (power_list == -1) {
						entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " -1");
						entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Prev");
						break;
							}
							if (power != 'Absorption' && power != 'Transferal' && power != 'Interplay' && power != 'Empathic_Mimicry') {
						entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add Powers." + power_cap + " dummy");
							let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_cap);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
					if (value_temp == 1 && abilityUtil.isEnabled(entity, 'heroes:empathic_mimicry', 'ability_call')) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " " + power_list + "");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Prev");
					break;
								}
					if (value_temp == 2 && abilityUtil.isEnabled(entity, 'heroes:empathic_mimicry', 'ability_uncall')) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s " + cycle_score + " " + power_list + "");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Empathic.Prev");
					break;
								}
							}
						}
					}
				}
                }
            });
    });