#How do I detect the type of damage whether it was due to a player or a fall?

1 messages · Page 1 of 1 (latest)

lean bison
#

world.afterEvents.entityHurt.subscribe(({ hurtEntity, damageSource }) => {

if (
hurtEntity.typeId === "minecraft:zombie"
) {
hurtEntity.runCommandAsync('/say player')
}
});

crystal lagoon
#

define the cause.

#

damageSource.cause

#

here's valid damage causes you can use.

#

and for detecting it was a player hitting, just define the damaging entity as player.
damageSource.damagingEntity.typeId == "minecraft:player

lean bison
#

😘 ty so much man