world.afterEvents.projectileHitEntity.subscribe((data) => {
for (const player of world.getPlayers()) {
const [projectile] = [data.projectile,];
if (projectile?.typeId == "minecraft:snowball") {
player.runCommandAsync('playsound random.orb')
const botloc = data.getEntityHit().location
const playerloc = player.location
const directionX = playerloc.x - botloc.x
const directionZ = playerloc.z - botloc.z
const magnitude = Math.sqrt(directionX * directionX + directionZ * directionZ)
const newdirX = directionX / magnitude
const newdirZ = directionZ / magnitude
hurtEntity.clearVelocity();
if (!player.hasTag('highkb')) {
data.getEntityHit().applyImpulse({ x: newdirX / 3.33, y: 0.36, z: newdirZ / 3.33 });
} else if (player.hasTag('highkb')) {
data.getEntityHit().applyImpulse({ x: newdirX / 3.33, y: 0.37, z: newdirZ / 3.33 });
}
}
}
});
i dont know how to get the entity that was hit by snowball