#How to make hurt detect?

1 messages · Page 1 of 1 (latest)

river isle
#

How to make hurt detect when snowball hits you and after you play command

wicked atlas
#

@river isle

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

world.afterEvents.entityHurt.subscribe((event) => {
    const { hurtEntity, damageSource } = event;
    
    if (hurtEntity.typeId === "minecraft:player" && 
        damageSource.cause === "projectile" && 
        damageSource.damagingEntity.typeId === "minecraft:snowball") {
        
        hurtEntity.runCommand("say You were hit by a snowball!");
        // Add any other command you want to run
    }
});
scenic osprey