import { world } from "@minecraft/server";
import { Entities } from "./Entities";

world.afterEvents.projectileHitBlock.subscribe((event) => {
    const { projectile } = event;
    const { block, faceLocation } = event.getBlockHit();
    if (projectile.typeId == Entities.baloon_projectile) {
        const baloon = block.dimension.spawnEntity(Entities.baloon, {
            x: block.location.x,
            y: block.location.y + 1,
            z: block.location.z,
        });
    }
    if (projectile.typeId == Entities.baloon_projectile_player) {
        const baloon = block.dimension.spawnEntity(Entities.baloon, {
            x: block.location.x,
            y: block.location.y + 1,
            z: block.location.z,
        });

        baloon.triggerEvent("baloon:sensor_player");
    }
});
