Beta
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");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 Copy
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
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].
Readonly
If true, this entity can breathe in air.
This property can throw when used.
If true, this entity can breathe in lava.
If true, this entity can breathe in solid blocks.
If true, this entity can breathe in water.
If true, the entity is able to breathe.
The entity that owns this component. The entity will be undefined if it has been removed.
If true, this entity will have visible bubbles while in water.
Time in seconds to recover breath to maximum.
Time in seconds between suffocation damage.
Time in seconds the entity can hold its breath.
Identifier of the component.
Static
List of blocks this entity can breathe in, in addition to the separate properties for classes of blocks.
This function can throw errors.
List of blocks this entity can't breathe in.
Whether the component is valid.
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.
Defines what blocks this entity can breathe in and gives them the ability to suffocate.
Example: pigBreathable.js