Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts
    Before events

    EntityHurtBeforeEvent

    The EntityHurtBeforeEvent interface in @minecraft/server.

    Interface in @minecraft/server

    Extends CancellableEvent

    import type { EntityHurtBeforeEvent } from '@minecraft/server';

    Subscribe to it with world.beforeEvents.entityHurt.

    import { world, type EntityHurtBeforeEvent } from '@minecraft/server';
    world.beforeEvents.entityHurt.subscribe((event: EntityHurtBeforeEvent) => {
    console.log('entityHurt', event.hurtEntity.typeId, event.damage, event.cancelKnockback);
    // Uncomment to stop it from happening.
    // event.cancel = true;
    });
    import { world } from '@minecraft/server';
    world.beforeEvents.entityHurt.subscribe((event) => {
    console.log('entityHurt', event.hurtEntity.typeId, event.damage, event.cancelKnockback);
    // Uncomment to stop it from happening.
    // event.cancel = true;
    });

    read-only

    readonly hurtEntity: Entity;

    The player or mob about to be hurt.

    Types
    damage: number;

    The damage before armour and resistance, which handlers may change.

    read-only

    readonly damageSource: EntityDamageSource;
    knockback: Vector3;

    The velocity the hit leaves the player or mob with, which handlers may change. A sprinting attacker’s hits push further, as PowerNukkitX’s do.

    Types
    cancelKnockback: boolean;

    True and the hit pushes nobody. True already for hurts with no push.

    WorldBeforeEvents.entityHurt, EntityHurtBeforeEventSignal.subscribe, EntityHurtBeforeEventSignal.unsubscribe

    From CancellableEvent: cancel