Mojira Archive
MCPE-165612

@minecraft/server.EntityDamageCause does not contain "sonic_boom"

The ranged attack of Warden could cause damage whose type is sonic_boom. But in fact, EntityDamageCause does not contain "sonic_boom". So if you subscribe the EntityHurtEventSignal and try to get the EntityHurtEvent.cause(until 1.19.60.25) or EntityHurtEvent.damageSource.cause(after 1.19.60.25) in the callback, instead of returning "sonic_boom", it will return undefined.

It it worth noting that you can only cause this type of damage by using minecraft:behavior.sonic_boom component. Because although the cause parameter of minecraft:hurt_on_condition component and minecraft:area_attack component accepts "sonic_boom", it actually uses "none" to do damage. But in blocks and items, the type parameter of damage event response does not accepts "sonic_boom" at all. /damage command does not support "sonic_boom" as well.

What is more, damage_sources parameter of minecraft:behavior.panic component and minecraft:behavior.play_dead component does not accept sonic_boom either.

Entity.applyDamage, which is added in 1.19.60.25, can apply certain type of damage to entity by passing EntityDamageSource.cause. However, "sonic_boom" is still unavailable and will throw an error (TypeError: Native optional type conversion failed).

Interestingly, if you try to use sonic_boom in minecraft:damage_sensor component (both of has_damage entity filter and cause parameter of trigger), you will find it working properly.

In summary, the table below will show all the problems.

name type status quo expectation note
@minecraft/server.EntityDamageCause Enumeration (SAPI) sonicBoom = undefined sonicBoom = "sonic_boom" -
@minecraft/server.Entity.applyDamage Function (SAPI)
TypeError: Native optional type conversion failed.
apply "sonic_boom" type damage and return a Boolean without throwing any errors the source parameter is
{ cause: "sonic_boom" }
@minecraft/server.EntityHurtEvent.cause String? (SAPI) undefined "sonic_boom" the ranged attack from Warden
minecraft:area_attack Entity Component (Data Driven) apply "none" type damage apply "sonic_boom" type damage the cause parameter is "sonic_boom"
minecraft:behavior.panic Entity Component (Data Driven)
[Json][error] | actor_definitions | Damage Source not found sonic_boom
get panicked after receiving "sonic_boom" type damage the damage_sources parameter includes "sonic_boom"
minecraft:behavior.play_dead Entity Component (Data Driven)
[Json][error] | actor_definitions | Damage Source not found: sonic_boom
play dead after receiving "sonic_boom" type damage the damage_sources parameter includes "sonic_boom"
minecraft:hurt_on_condition Entity Component (Data Driven) apply "none" type damage apply "sonic_boom" type damage the cause parameter is "sonic_boom"
damage Blocks/Items Event Response (Data Driven)
[AI][error]-Unknown damage type in damage response
apply "sonic_boom" type damage the type parameter is "sonic_boom"
/damage Command
Syntax error: Unexpected "sonic_boom" at "/damage @e 1 >>sonic_boom<<"
apply "sonic_boom" type damage the cause parameter is "sonic_boom"