(function () {
    let ClientboundSetEntityMotionPacket = Java.loadClass('net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket');


StartupEvents.registry('palladium:abilities', (event) => {

    event.create('blue:shield')

        .icon(palladium.createItemIcon('palladium:vibranium_circuit'))

        .addProperty('radius', 'integer', 10, 'Radius in which surrounding entities will be damaged')
		.addProperty('tag_ex', 'string', 'exclusion_tag', 'Tag that exlcudes entities if desired')
        .addProperty("motion_scale", "float", 1.1, "Motion Scale")

        .tick((entity, entry, holder, enabled) => {
            if (enabled) {
				const containsTag = entry.getPropertyByName('tag_ex');
				const reversal_state = entry.getPropertyByName('reversal_state');
                const radius = entry.getPropertyByName('radius') * 2.0;
                const targets = entity.serverLevel().getEntities(entity, AABB.ofSize(entity.position(), radius, radius, radius)).toArray();
				let current_x = entity.x
				let current_y = entity.y
				let current_z = entity.z
                for (let j = 0; j < targets.length; j++) {
                        let box = AABB.ofSize(entity.position(), radius, radius, radius);
                        let entities = entity.serverLevel().getEntities(entity, box).toArray();
                        let motionscale = entry.getPropertyByName("motion_scale")
                        let move = entity.getLookAngle().scale(motionscale);
                        for (let i = 0; i < entities.length; i++) {
                          {

                        entities[i].addMotion(((((radius / ((entities[i].x - current_x) + 0.00001))* (1 + 5)^2.4) / 1000)), ((((radius / ((entities[i].y - current_y) + 0.00001))* (1 + 5)^2.4) / 1000) * -1), ((((radius / ((entities[i].z - current_z) + 0.00001))* (1 + 5)^2.4) / 1000)));
								if (entities[i].isPlayer()) {
                        entities[i].connection.send(new ClientboundSetEntityMotionPacket(entities[i]));
                    }
                        }
                    }
                }
            }
        })
});
})();
