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

    Class in @minecraft/server

    Extends EntityComponent

    An entity’s health.

    import { EntityHealthComponent } from '@minecraft/server';
    import { world, type EntityHealthComponent } from '@minecraft/server';
    for (const player of world.getAllPlayers()) {
    const component: EntityHealthComponent | undefined = player.getComponent('minecraft:health');
    if (component) {
    console.log(player.name, component.currentValue);
    }
    }
    import { world } from '@minecraft/server';
    for (const player of world.getAllPlayers()) {
    const component = player.getComponent('minecraft:health');
    if (component) {
    console.log(player.name, component.currentValue);
    }
    }

    read-only

    readonly typeId: "minecraft:health";

    read-only

    readonly entity: Entity;
    Types

    read-only

    readonly isValid: boolean;

    read-only

    readonly currentValue: number;

    read-only

    readonly effectiveMax: number;

    read-only

    readonly effectiveMin: number;

    read-only

    readonly defaultValue: number;

    The maximum, in Basalt.

    setCurrentValue(value: number): boolean;

    Sets the health, within the maximum; zero kills.

    Parameters
    value
    number
    Returns
    boolean
    resetToMaxValue(): void;
    resetToDefaultValue(): void;
    resetToMinValue(): void;

    EntityComponentTypeMap.minecraft:health, EntityComponentTypeMap.health