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

Example

pigBreathable.js

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

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

Hierarchy

Constructors

Properties

breathesAir: boolean

Remarks

If true, this entity can breathe in air.

Throws

This property can throw when used.

breathesLava: boolean

Remarks

If true, this entity can breathe in lava.

Throws

This property can throw when used.

breathesSolids: boolean

Remarks

If true, this entity can breathe in solid blocks.

Throws

This property can throw when used.

breathesWater: boolean

Remarks

If true, this entity can breathe in water.

Throws

This property can throw when used.

entity: Entity

Remarks

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

generatesBubbles: boolean

Remarks

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

Throws

This property can throw when used.

inhaleTime: number

Remarks

Time in seconds to recover breath to maximum.

Throws

This property can throw when used.

suffocateTime: number

Remarks

Time in seconds between suffocation damage.

Throws

This property can throw when used.

totalSupply: number

Remarks

Time in seconds the entity can hold its breath.

Throws

This property can throw when used.

typeId: string

Remarks

Identifier of the component.

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

Methods

  • Returns BlockPermutation[]

    Remarks

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

    Throws

    This function can throw errors.

  • Returns BlockPermutation[]

    Remarks

    List of blocks this entity can't breathe in.

    Throws

    This function can throw errors.

  • Returns boolean

    Whether the component is valid.

    Remarks

    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.