
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:dimensional_shift')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
            .addProperty("id_scoreboard", "string", "Score.Board", "Scoreboard used to identify storage id")
            .addProperty("dimension_id", "string", "minecraft:the_overworld", "Scoreboard used for timer")
            .addProperty("dimension_size", "string", "Score.Board", "Scoreboard used for dimension size")
					
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
					
					const score_id = entry.getPropertyByName('id_scoreboard');
					const dim_size = entry.getPropertyByName('dimension_size');
					const dim_id = entry.getPropertyByName('dimension_id');
					let dimension = entity.getLevel().getDimension();
					let username_name = entity.getName().getString();
                    let username = entity.username;

					
					let scoreboard = Utils.server.scoreboard;

                    let scoreboard_obj = scoreboard.getObjective(entry.getPropertyByName("id_scoreboard"));
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					
					let scoreboard_obj_size = scoreboard.getObjective(entry.getPropertyByName("dimension_size"));
                    let score_size = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_size);
                    let value_size = score_size.getScore();
					
					if (dimension.toString() != dim_id.toString()) {
					entity.persistentData.pocket_dimension = dimension.toString()
					entity.persistentData.pocket_x = entity.getX();
					entity.persistentData.pocket_y = entity.getY();
					entity.persistentData.pocket_z = entity.getZ();
					
					let dimension_origin = entity.persistentData.pocket_dimension;
					let dimension_x = entity.persistentData.pocket_x;
					let dimension_y = entity.persistentData.pocket_y;
					let dimension_z = entity.persistentData.pocket_z;
					
					let pos_x_before = entity.persistentData.pocket_x_leave
					if (pos_x_before == null || pos_x_before > (value * 250) + (value_size + 7) || pos_x_before < (value * 250) - (value_size + 7)) {
						entity.persistentData.pocket_x_leave = (value * 250)
						pos_x_before = (value * 250)
					}
					let pos_y_before = entity.persistentData.pocket_y_leave
					if (pos_y_before == null || pos_y_before > 156 + 9 || pos_y_before < 156 - 8) {
						entity.persistentData.pocket_y_leave = 150
						pos_y_before = 150
					}
					let pos_z_before = entity.persistentData.pocket_z_leave
					if (pos_z_before == null || pos_z_before > (value * 250) + (value_size + 7) || pos_z_before < (value * 250) - (value_size + 7)) {
						entity.persistentData.pocket_z_leave = (value * 250)
						pos_z_before = (value * 250)
					}
				
					entity.server.runCommandSilent("execute as " + username + " at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " run summon minecraft:armor_stand ~ ~ ~ {CustomName:\'{\"text\":\"Failsafe_Stand\"}\',Invisible:1,NoGravity:1,Marker:1,Palladium:{Properties:{superpowers:[\"heroes:pocket_dimension\"]}},Tags:[\"Heroes.Pocket.Failsafe\"]}");
					
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] run effect give @s minecraft:levitation 2 0 true");
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] run effect give @s minecraft:slow_falling 4 255 true");
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] in " + dim_id + " positioned " + pos_x_before + " " + pos_y_before + " " + pos_z_before + " run tp @s ~ ~ ~");
					entity.server.runCommandSilent("execute as " + username + " at @s run particle minecraft:end_rod ~ ~1 ~ 1 0.65 1 0 100");
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] in " + dim_id + " positioned " + pos_x_before + " " + pos_y_before + " " + pos_z_before + " run particle minecraft:end_rod ~ ~1 ~ 1 0.65 1 0 100");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " run forceload add " + (value * 250) + " " + (value * 250) + " " + (value * 250) + " " + (value * 250));
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 147 " + (value * 250) + " run fill ~34 ~ ~34 ~-34 ~ ~-34 heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 166 " + (value * 250) + " run fill ~34 ~ ~34 ~-34 ~ ~-34 heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~ ~ ~ run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~18 ~ ~ run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~-18 ~ ~ run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~ ~ ~18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~ ~ ~-18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~18 ~ ~18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~-18 ~ ~18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~18 ~ ~-18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~-18 ~ ~-18 run fill ~18 ~9 ~18 ~-18 ~-8 ~-18 air replace heroes:hold_block_3");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~ ~ ~" + (value_size + 7) + " run fill ~" + (value_size + 7) + " ~9 ~ ~-" + (value_size + 7) + " ~-8 ~" + (28 - value_size) + " heroes:hold_block_3 keep");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~ ~ ~-" + (value_size + 7) + " run fill ~" + (value_size + 7) + " ~9 ~ ~-" + (value_size + 7) + " ~-8 ~-" + (28 - value_size) + " heroes:hold_block_3 keep");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~" + (value_size + 7) + " ~ ~ run fill ~ ~9 ~" + (value_size + 7) + " ~" + (28 - value_size) + " ~-8 ~-" + (value_size + 7) + " heroes:hold_block_3 keep");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " positioned " + (value * 250) + " 156 " + (value * 250) + " positioned ~-" + (value_size + 7) + " ~ ~ run fill ~ ~9 ~" + (value_size + 7) + " ~-" + (28 - value_size) + " ~-8 ~-" + (value_size + 7) + " heroes:hold_block_3 keep");
					entity.server.runCommandSilent("execute as " + username + " as @s at @s in " + dim_id + " run forceload remove " + (value * 250) + " " + (value * 250) + " " + (value * 250) + " " + (value * 250));
					}
					
					
					if (dimension.toString() == dim_id.toString()) {
					entity.persistentData.pocket_x_leave = entity.getX();
					entity.persistentData.pocket_y_leave = entity.getY();
					entity.persistentData.pocket_z_leave = entity.getZ();
					
					
					let dimension_origin = entity.persistentData.pocket_dimension;
					let dimension_x = entity.persistentData.pocket_x;
					let dimension_y = entity.persistentData.pocket_y;
					let dimension_z = entity.persistentData.pocket_z;
					entity.server.runCommandSilent("execute as " + username + " at @s run particle minecraft:end_rod ~ ~1 ~ 1 0.65 1 0 100");
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] run effect give @s minecraft:slow_falling 2 255 true");
					entity.server.runCommandSilent("execute as " + username + " at @s as @e[distance=..3,type=!armor_stand,type=!marker] in " + dimension_origin + " run tp @s " + dimension_x + " " + dimension_y + " " + dimension_z);
					}
					
                }
          
			});
    });