import { world } from "@minecraft/server";
/* 
Manages if an entity hits another one
applies knockback on the hit entity
*/

export function entityHitEntityController(event) {
  const typeId = event.projectile.typeId;
  if (typeId == undefined) {
    return;
  }
  if (event.projectile.typeId == "minecraft:arrow" && event.getEntityHit().entity.typeId.includes("ent_co:tnt_")) {
    if (event.projectile.extinguishFire(false)) {
      event.getEntityHit().entity.runCommand("/event entity @s ent_co:start_exploding");
    }
  }
}
