
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:ability_transfer')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty('reach_range', 'integer', 3, 'Range the ability can reach')
			.addProperty('stam_percent', 'float', 0.05, 'Percent of stamina used in a transfer')

            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
                    let scoreboard = Utils.server.scoreboard;
					const reach_range = entry.getPropertyByName('reach_range');
					const stam_percent = entry.getPropertyByName('stam_percent');
					
					let scoreboard_obj = scoreboard.getObjective('Heroes.Power.Icon');
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					

					let target_entity = entity.rayTrace(reach_range).entity
					let entity_target_true = 0
					

					if (target_entity != null && target_entity.type != "minecraft:item" && target_entity.type != "minecraft:item_frame" && target_entity.type != "minecraft:glow_item_frame" && target_entity.type != "minecraft:armor_stand" && target_entity.type != "palladium:suit_stand") {

					if (!target_entity.isPlayer()) {
					entity_target_true = target_entity.uuid;
						} else {
								entity_target_true = target_entity.getGameProfile().getName();
						}
						
						
						if (value >= 0) {
							let scoreboard_obj_stam = scoreboard.getObjective('Heroes.Stamina.Max');
							let score_stam = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_stam);
							let value_stam = score_stam.getScore();
							if (entity.uuid != '7e2b5ebc-3ea1-4278-8ca9-1109067f00f4') {
								let power_cost = global['ability_cost_' + value].toString();
								let true_cost = parseFloat(power_cost)
							entity.server.runCommandSilent("execute as " + entity.uuid + " at @s run scoreboard players remove @s Heroes.Stamina.Max " + JavaMath.ceil(value_stam * ((true_cost / 6) / 100) * -1) + "");
							}
							
							
						let power_max = global.power_amount;
						let power = global['ability_' + value];
						let power_score = 0
						if (!target_entity.isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity_target_true, Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(target_entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
							}
						}
					if (power_score == 0) {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] run tag @s add Heroes.Enabled");
					entity.server.runCommandSilent("execute as " + username + " at @s[tag=Heroes.Uncatalyzed] run tag " + entity_target_true + " add Heroes.Uncatalyzed");

					
					if (power == 'Ability_Replication') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Replication.Slots.True >< " + username + " Heroes.Replication.Slots.True");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower1 >< " + username + " Heroes.ReplicationPower1");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower2 >< " + username + " Heroes.ReplicationPower2");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower3 >< " + username + " Heroes.ReplicationPower3");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower4 >< " + username + " Heroes.ReplicationPower4");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower5 >< " + username + " Heroes.ReplicationPower5");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Stockpile.Replicated.Energy >< " + username + " Heroes.Stockpile.Replicated.Energy");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Bone.Var.Replicated >< " + username + " Heroes.Bone.Var.Replicated");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Levitation.Speed.Base.Replication >< " + username + " Heroes.Levitation.Speed.Base.Replication");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Ability_Replication matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Pocket.Id.Replicated >< " + username + " Heroes.Pocket.Id.Replicated");
					}
					
					if (power == 'Levitation') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Levitation matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Levitation.Speed.Base >< " + username + " Heroes.Levitation.Speed.Base");
					
	
	
					}
					if (power == 'Bone_Protrusion') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Bone_Protrusion matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Bone.Var.Base >< " + username + " Heroes.Bone.Var.Base");
					}
					if (power == 'Empathic_Mimicry') {
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Empathic_Mimicry=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Stockpile.Empathic.Energy >< " + username + " Heroes.Stockpile.Empathic.Energy");
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Empathic_Mimicry=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Bone.Var.Empathic >< " + username + " Heroes.Bone.Var.Empathic");
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Empathic_Mimicry=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Levitation.Speed.Base.Empathic >< " + username + " Heroes.Levitation.Speed.Base.Empathic");
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Empathic_Mimicry=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Pocket.Id.Empathic >< " + username + " Heroes.Pocket.Id.Empathic");
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Empathic_Mimicry=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Replication.Slots.Empathic >< " + username + " Heroes.Replication.Slots.Empathic");
						
						for (let power_empathic_max = 0; power_empathic_max <= power_max; power_empathic_max++) {
						let power_empathic = global['ability_' + power_empathic_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_empathic);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 2) {
						entity.server.runCommandSilent("execute as " + username + " at @s as unless score " + entity_target_true + " Powers.Empathic_Mimicry matches 1.. run scoreboard players set @s Powers.Empathic." + power_empathic + " 1");
									}
								}
							}
							
						for (let power_empathic_max = 0; power_empathic_max <= power_max; power_empathic_max++) {
						let power_empathic = global['ability_' + power_empathic_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_empathic);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 1) {
						entity.server.runCommandSilent("execute as " + username + " at @s as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score @s Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Powers.Empathic." + power_empathic + " >< " + username + " Powers.Empathic." + power_empathic + "");
									}
								}
							}
					}							
						
						if (power == 'Intuitive_Aptitude') {
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Intuitive_Aptitude=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Stockpile.Intuitive.Energy >< " + username + " Heroes.Stockpile.Intuitive.Energy");
						
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Intuitive_Aptitude=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Bone.Var.Intuitive >< " + username + " Heroes.Bone.Var.Intuitive");
						
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Intuitive_Aptitude=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Levitation.Speed.Base.Intuitive >< " + username + " Heroes.Levitation.Speed.Base.Intuitive");
						
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Intuitive_Aptitude=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Pocket.Id.Intuitive >< " + username + " Heroes.Pocket.Id.Intuitive");
						
						entity.server.runCommandSilent("execute as " + username + " at @s[scores={Powers.Intuitive_Aptitude=1..}] as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score " + entity_target_true + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Replication.Slots.Intuitive >< " + username + " Heroes.Replication.Slots.Intuitive");
						
						
						for (let power_intuitive_max = 0; power_intuitive_max <= power_max; power_intuitive_max++) {
						let power_intuitive = global['ability_' + power_intuitive_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Intuitive.' + power_intuitive);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 1) {
						entity.server.runCommandSilent("execute as " + username + " at @s as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score @s Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Powers.Intuitive." + power_intuitive + " >< " + username + " Powers.Intuitive." + power_intuitive + "");
									}
								}
							}
						}
						
						if (power == 'Stockpile') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Stockpile matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Stockpile.True.Energy >< " + username + " Heroes.Stockpile.True.Energy");
					}
					
					if (power == 'Pocket_Reality') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score " + username + " Powers." + power + " matches 1.. unless score @s Powers.Pocket_Reality matches 1.. run scoreboard players operation " + entity_target_true + " Heroes.Pocket.Id.True >< " + username + " Heroes.Pocket.Id.True");
					}
					
					
					entity.server.runCommandSilent("execute as " + username + " at @s anchored eyes if score @s Heroes.Power.Icon matches " + value + " unless score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation " + entity_target_true + " Powers." + power + " >< @s Powers." + power + "");

					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s add Heroes.Prock");
					entity.server.runCommandSilent("execute as " + username + " at @s run playsound minecraft:entity.vex.ambient master @a ~ ~ ~ 2 2");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s add Heroes.Next");
							}
						}
					}
				}
            });
    });