import { 
    system, 
    ScriptEventCommandMessageAfterEvent,
    Entity,
    world,
    EntityHurtAfterEvent
} from "@minecraft/server";

const monsterNo11Id = "pm_m8:monster_no_11";


//wrath_of_the_ocean
const oceanNameSpace = "pm_m8_monster_no_11_ocean";
const scriptEventOption = {namespaces : [oceanNameSpace]};


/**
 * @param {Entity} entity 
 * @param {number} distance
 * @returns {import("@minecraft/server").EntityQueryOptions}
 */
function entityQueryOptionCreator(entity, distance){
    return {
        location: entity.location,
        maxDistance: distance
    }
}

/**
 * @param {ScriptEventCommandMessageAfterEvent} event 
 */
function oceanTp(event){
    if (!event.sourceEntity) return;
    const sourceEntity = event.sourceEntity;
    const aroundEntities = sourceEntity.dimension.getEntities(entityQueryOptionCreator(sourceEntity, 10));

    aroundEntities.forEach(ele => {
        ele.teleport(sourceEntity.location);
    });
}


system.afterEvents.scriptEventReceive.subscribe(oceanTp, scriptEventOption);