Adds a timer for the entity to grow up. It can be accelerated by giving the entity the items it likes as defined by feedItems.

Example

pigAgeableInfo.js

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

const pig = world
.getDimension("nether")
.spawnEntity("minecraft:pig", { x: 0, y: 0, z: 0 });
const ageable = pig.getComponent("ageable");
const growUpEvent = ageable.growUp.eventName;
world.sendMessage(`Pig ageable duration: ${ageable.duration}`);
world.sendMessage(`Pig grow up event: ${growUpEvent}`);
world.sendMessage(`Pig drop items: ${ageable.getDropItems()}`);
world.sendMessage(`Pig feed items: ${ageable.getFeedItems()}`);

Hierarchy

Constructors

Properties

duration: number

Remarks

Amount of time before the entity grows up, -1 for always a baby.

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.

growUp: Trigger

Remarks

Event that runs when this entity grows up.

Throws

This property can throw when used.

transformToItem: string

Remarks

The feed item used will transform into this item upon successful interaction.

Throws

This property can throw when used.

typeId: string

Remarks

Identifier of the component.

componentId: "minecraft:ageable" = 'minecraft:ageable'

Methods

  • Returns string[]

    Remarks

    List of items that the entity drops when it grows up.

    Throws

    This function can throw errors.

  • Returns EntityDefinitionFeedItem[]

    Remarks

    List of items that can be fed to the entity. Includes 'item' for the item name and 'growth' to define how much time it grows up by.

    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.