
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:pocket_realization')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))

            .firstTick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					let scoreboard = Utils.server.scoreboard;
					let scoreboard_obj = scoreboard.getObjective("Heroes.Pocket.Id");
					if (scoreboard_obj != null) {
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					entity.server.runCommandSilent("execute as " + username + " at @s run particle minecraft:end_rod ~ ~ ~ 3 3 3 0 10000");
					entity.server.runCommandSilent("execute as " + username + " at @s run playsound heroes:heroes.pocket_dim.ding.sfx master @a");
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players add @s Heroes.Concentration.Hold 3");
					entity.server.runCommandSilent("execute as " + username + " at @s positioned ~ ~2 ~ run summon armor_stand ~ ~ ~ {Invisible:1,Marker:1,Palladium:{Properties:{superpowers:[\"heroes:pocket_domain\"]}},Tags:[\"Heroes.Pocket.Failsafe\", \"Pocket_Domain.Init\"]}");
					
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @e[tag=Pocket_Domain.Init] Heroes.Pocket.Id " + value + "");
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @e remove Pocket_Domain.Init");
					
					const radius = 16; 

					entity.persistentData.pocket_x_domain = entity.x
					entity.persistentData.pocket_y_domain = entity.y + 2
					entity.persistentData.pocket_z_domain = entity.z
for (let x = -radius; x <= radius; x++) {
    for (let y = -radius; y <= radius; y++) {
        for (let z = -radius; z <= radius; z++) {
            let distance = Math.sqrt((x * x) + (y * y) + (z * z));
			if (distance >= (radius - 1) && distance <= radius) {
			let block = entity.getLevel().getBlock(entity.x + x, entity.y + y, entity.z + z);
			
			let pos = new BlockPos(entity.x + x, entity.y + y, entity.z + z)
			let block_hold = entity.getLevel().getBlockState(pos)
			if (block_hold.isAir() || block.id == "minecraft:snow" || block.id == "minecraft:grass" || block.id == "minecraft:fire" || block.id == "minecraft:tall_grass" || block.id == "minecraft:large_fern") {
			block.set('heroes:pocket_reality_domain')
						}
						if (block.id == "minecraft:water") {
			block.set('heroes:pocket_reality_domain_water')
					}
					if (block.id == "minecraft:lava") {
			block.set('heroes:pocket_reality_domain_lava')
						}
					}
				}
			}
        }
	let y = -1
	for (let x = -radius; x <= radius; x++) {
			for (let z = -radius; z <= radius; z++) {
            let distance = Math.sqrt((x * x) + (y * y) + (z * z));
			if (distance <= radius) {
			let block = entity.getLevel().getBlock(entity.x + x, entity.y + y, entity.z + z);
			let pos = new BlockPos(entity.x + x, entity.y + y, entity.z + z)
			let block_hold = entity.getLevel().getBlockState(pos)
			if (block_hold.isAir() || block.id == "minecraft:snow" || block.id == "minecraft:grass" || block.id == "minecraft:fire" || block.id == "minecraft:tall_grass" || block.id == "minecraft:large_fern") {
			block.set('heroes:pocket_reality_domain')
					}
					if (block.id == "minecraft:water") {
			block.set('heroes:pocket_reality_domain_water')
					}
					if (block.id == "minecraft:lava") {
			block.set('heroes:pocket_reality_domain_lava')
					}
				}
			}  
		}
	}
				
				}
            })
			.tick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					let scoreboard = Utils.server.scoreboard;
					let scoreboard_obj = scoreboard.getObjective("Heroes.Pocket.Id");
					if (scoreboard_obj != null) {
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					
					let x = entity.persistentData.pocket_x_domain
					let y = entity.persistentData.pocket_y_domain
					let z = entity.persistentData.pocket_z_domain
					
					entity.server.runCommandSilent("execute as " + username + " at @s positioned " + x + " " + y + " " + z + " run scoreboard players set @e[type=armor_stand,distance=..2,scores={Heroes.Pocket.Id=" + value + "}] Heroes.Pocket_Dimension.Domain.Timer 5");
					}
					
					
						
				
				}
            })
			.lastTick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					let scoreboard = Utils.server.scoreboard;
					let scoreboard_obj = scoreboard.getObjective("Heroes.Concentration.Max");
					if (scoreboard_obj != null) {
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Heroes.Concentration.Hold " + (value + 1));
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s add Heroes.Pocket.Domain.CD");
					}
				
				}
            });
    });