Script API - v1.21.100
    Preparing search index...

    Class EntityBreathableComponent

    Defines what blocks this entity can breathe in and gives them the ability to suffocate.

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

    const pig = world.getDimension("overworld").getEntities({ type: "minecraft:pig" })[0];
    const breathable = pig.getComponent("breathable");
    if (breathable) {
    breathable.breathesAir;
    breathable.breathesLava;
    breathable.breathesSolids;
    breathable.breathesWater;
    breathable.generatesBubbles;
    breathable.inhaleTime;
    breathable.suffocateTime;
    breathable.totalSupply;
    breathable.getBreatheBlocks();
    breathable.getNonBreatheBlocks();
    breathable.airSupply = 100; // Assuming 100 as an example value
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    airSupply: number

    The current air supply of the entity.

    This property can't be edited in read-only mode.

    Will throw an error if the air supply is out of bounds [suffocationTime, maxAirSupply].

    This property can't be read in early-execution mode.

    breathesAir: boolean

    If true, this entity can breathe in air.

    This property can throw when used.

    This property can't be read in early-execution mode.

    breathesLava: boolean

    If true, this entity can breathe in lava.

    This property can throw when used.

    This property can't be read in early-execution mode.

    breathesSolids: boolean

    If true, this entity can breathe in solid blocks.

    This property can throw when used.

    This property can't be read in early-execution mode.

    breathesWater: boolean

    If true, this entity can breathe in water.

    This property can throw when used.

    This property can't be read in early-execution mode.

    canBreathe: boolean

    If true, the entity is able to breathe.

    This property can throw when used.

    This property can't be read in early-execution mode.

    entity: Entity

    The entity that owns this component. The entity will be undefined if it has been removed.

    This property can throw when used.

    InvalidEntityError

    This property can't be read in early-execution mode.

    generatesBubbles: boolean

    If true, this entity will have visible bubbles while in water.

    This property can throw when used.

    This property can't be read in early-execution mode.

    inhaleTime: number

    Time in seconds to recover breath to maximum.

    This property can throw when used.

    This property can't be read in early-execution mode.

    isValid: boolean

    Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.

    This property can't be read in early-execution mode.

    suffocateTime: number

    Time in seconds between suffocation damage.

    This property can throw when used.

    This property can't be read in early-execution mode.

    totalSupply: number

    Time in seconds the entity can hold its breath.

    This property can throw when used.

    This property can't be read in early-execution mode.

    typeId: string

    Identifier of the component.

    This property can't be read in early-execution mode.

    componentId: "minecraft:breathable" = 'minecraft:breathable'

    Methods

    • Returns BlockPermutation[]

      List of blocks this entity can breathe in, in addition to the separate properties for classes of blocks.

      This function can throw errors.

      This function can't be called in early-execution mode.

    • Returns BlockPermutation[]

      List of blocks this entity can't breathe in.

      This function can throw errors.

      This function can't be called in early-execution mode.