endstone/actor

Classes

NameDescription
ActorRepresents a base actor in the level.
ItemRepresents a base actor in the level.
MobRepresents a mobile entity (i.e. living entity), such as a monster or player.

classActor

Defined in <endstone/actor/actor.h>

Bases: CommandSender

Represents a base actor in the level.

Methods

NameDescription
asMobGets an Actor as Mob.
asItemGets an Actor as Item.
getTypeGet the type of the actor.
getRuntimeId
getLocation
getVelocity
isOnGround
isInWater
isInLava
getLevel
getDimension
setRotation
teleport
teleport
getIdReturns a unique id for this actor.
remove
isDeadReturns true if this actor has been marked for removal.
isValid
getScoreboardTagsReturns a list of scoreboard tags for this actor.
addScoreboardTagAdds a tag to this actor.
removeScoreboardTagRemoves a given tag from this actor.
isNameTagVisibleChecks if the actor's name tag is currently visible.
setNameTagVisibleSets if the actor's name tag is visible or not.
isNameTagAlwaysVisibleChecks if the actor's name tag is always visible.
setNameTagAlwaysVisibleSets whether the actor's name tag should always be visible.
getNameTagGets the current name tag of the actor.
setNameTagSets the name tag for the actor.
getScoreTagGets the current score tag of the actor.
setScoreTagSets the score tag for the actor.

methasMobabstractconst

Mob* asMob() const =0

Gets an Actor as Mob.

Returns

TypeDescription
Mob*Mob, nullptr if not an Mob

methasItemabstractconst

Item* asItem() const =0

Gets an Actor as Item.

Returns

TypeDescription
Item*Item, nullptr if not an Item

methgetTypeabstractconst

std::string getType() const =0

Get the type of the actor.

This method returns the type of the actor as a string, for example, minecraft:pig.

Returns

TypeDescription
std::stringThe type of the actor.

methgetRuntimeIdabstractconst

std::uint64_t getRuntimeId() const =0

Returns the runtime id for this actor

Returns

TypeDescription
std::uint64_tRuntime id for this actor

methgetLocationabstractconst

Location getLocation() const =0

Gets the actor's current position

Returns

TypeDescription
Locationa new copy of Location containing the position of this actor

methgetVelocityabstractconst

Vector getVelocity() const =0

Gets this actor's current velocity

Returns

TypeDescription
VectorCurrent traveling velocity of this actor

methisOnGroundabstractconst

bool isOnGround() const =0

Returns true if the actor is supported by a block.

Returns

TypeDescription
boolTrue if actor is on ground.

methisInWaterabstractconst

bool isInWater() const =0

Returns true if the actor is in water.

Returns

TypeDescription
boolTrue if the actor is in water.

methisInLavaabstractconst

bool isInLava() const =0

Returns true if the actor is in lava.

Returns

TypeDescription
boolTrue if the actor is in lava.

methgetLevelabstractconst

Level& getLevel() const =0

Gets the current Level this actor resides in

Returns

TypeDescription
Level&The current Level this actor resides in

methgetDimensionabstractconst

Dimension& getDimension() const =0

Gets the current Dimension this actor resides in

Returns

TypeDescription
Dimension&The current Dimension this actor resides in

methsetRotationabstract

void setRotation(float yaw, float pitch) =0

Note that if the actor is affected by AI, it may override this rotation.

Parameters

NameTypeDescription
yawfloatRotation around the up axis (Y axis)
pitchfloatRotation around the right axis (X axis)

Returns

TypeDescription
voidSets the actor's rotation.

methteleportabstract

bool teleport(const Location& location) =0

Parameters

NameTypeDescription
locationconst Location&New location to teleport this actor to

Returns

TypeDescription
boolTeleports this actor to the given location.

methteleportabstract

bool teleport(const Actor& target) =0

Teleports this actor to the target Actor.

Parameters

NameTypeDescription
targetconst Actor&Actor to teleport this actor to

methgetIdabstractconst

std::int64_t getId() const =0

Returns a unique id for this actor.

Returns

TypeDescription
std::int64_tActor id

methremoveabstract

void remove() =0

Remove this actor from the level.

If you are trying to remove a Player, use Player::kick instead.

methisDeadabstractconst

bool isDead() const =0

Returns true if this actor has been marked for removal.

Returns

TypeDescription
boolTrue if it is dead.

methisValidabstractconst

bool isValid() const =0

Returns false if the entity has died, been despawned for some other reason, or has not been added to the level.

Returns

TypeDescription
boolTrue if valid.

methgetScoreboardTagsabstractconst

std::vector<std::string> getScoreboardTags() const =0

Returns a list of scoreboard tags for this actor.

Returns

TypeDescription
std::vector<std::string>a list of scoreboard tags for this actor

methaddScoreboardTagabstractconst

bool addScoreboardTag(std::string tag) const =0

Adds a tag to this actor.

Parameters

NameTypeDescription
tagstd::stringthe tag to add

Returns

TypeDescription
booltrue if the tag was successfully added, false if the tag already exists.

methremoveScoreboardTagabstractconst

bool removeScoreboardTag(std::string tag) const =0

Removes a given tag from this actor.

Parameters

NameTypeDescription
tagstd::stringthe tag to remove

Returns

TypeDescription
booltrue if the tag was successfully removed, false if the tag does not exist.

methisNameTagVisibleabstractconst

bool isNameTagVisible() const =0

Checks if the actor's name tag is currently visible.

Returns

TypeDescription
boolTrue if the name tag is visible, false otherwise.

methsetNameTagVisibleabstract

void setNameTagVisible(bool visible) =0

Sets if the actor's name tag is visible or not.

Parameters

NameTypeDescription
visibleboolTrue to make the name tag visible, false to hide it.

methisNameTagAlwaysVisibleabstractconst

bool isNameTagAlwaysVisible() const =0

Checks if the actor's name tag is always visible.

Returns

TypeDescription
boolTrue if the name tag is always visible, false otherwise.

methsetNameTagAlwaysVisibleabstract

void setNameTagAlwaysVisible(bool visible) =0

Sets whether the actor's name tag should always be visible.

Parameters

NameTypeDescription
visibleboolTrue to make the name tag always visible, false to disable always visibility.

methgetNameTagabstractconst

std::string getNameTag() const =0

Gets the current name tag of the actor.

Returns

TypeDescription
std::stringThe name tag.

methsetNameTagabstract

void setNameTag(std::string name) =0

Sets the name tag for the actor.

Parameters

NameTypeDescription
namestd::stringThe new name tag to set.

methgetScoreTagabstractconst

std::string getScoreTag() const =0

Gets the current score tag of the actor.

Returns

TypeDescription
std::stringThe score tag.

methsetScoreTagabstract

void setScoreTag(std::string score) =0

Sets the score tag for the actor.

Parameters

NameTypeDescription
scorestd::stringThe new score tag to set.

classItem

Defined in <endstone/actor/item.h>

Bases: Actor

Represents a base actor in the level.

Methods

NameDescription
getItemStackGets the item stack associated with this item drop.
setItemStackSets the item stack associated with this item drop.
getPickupDelayGets the delay before this Item is available to be picked up by players.
setPickupDelaySets the delay before this Item is available to be picked up by players.
setUnlimitedLifetimeSets if this Item should live forever.
isUnlimitedLifetimeGets if this Item lives forever.
setThrowerSet the thrower of this item.
getThrowerGet the thrower of this item.

methgetItemStackabstractconst

ItemStack getItemStack() const =0

Gets the item stack associated with this item drop.

Returns

TypeDescription
ItemStackAn item stack.

methsetItemStackabstract

void setItemStack(const ItemStack& stack) =0

Sets the item stack associated with this item drop.

Parameters

NameTypeDescription
stackconst ItemStack&An item stack.

methgetPickupDelayabstractconst

int getPickupDelay() const =0

Gets the delay before this Item is available to be picked up by players.

Returns

TypeDescription
intRemaining delay

methsetPickupDelayabstract

void setPickupDelay(int delay) =0

Sets the delay before this Item is available to be picked up by players.

Parameters

NameTypeDescription
delayintNew delay

methsetUnlimitedLifetimeabstract

void setUnlimitedLifetime(bool unlimited) =0

Sets if this Item should live forever.

Parameters

NameTypeDescription
unlimitedbooltrue if the lifetime is unlimited

methisUnlimitedLifetimeabstractconst

bool isUnlimitedLifetime() const =0

Gets if this Item lives forever.

Returns

TypeDescription
booltrue if the lifetime is unlimited

methsetThrowerabstract

void setThrower(std::optional<std::int64_t> thrower) =0

Set the thrower of this item.

Note

The thrower is the entity which dropped the item.

Parameters

NameTypeDescription
throwerstd::optional<std::int64_t>unique id of thrower

methgetThrowerabstractconst

std::optional<std::int64_t> getThrower() const =0

Get the thrower of this item.

Note

The thrower is the entity which dropped the item.

Returns

TypeDescription
std::optional<std::int64_t>unique id of thrower

classMob

Defined in <endstone/actor/mob.h>

Bases: Actor

Represents a mobile entity (i.e. living entity), such as a monster or player.

Methods

NameDescription
isGlidingChecks to see if an actor is gliding, such as using an Elytra.
getHealthGets the entity's health from 0 to its max possible value, where 0 is dead.
setHealth
getMaxHealthGets the maximum health this entity has.
setMaxHealthSets the maximum health this entity can have.

methisGlidingabstractconst

bool isGliding() const =0

Checks to see if an actor is gliding, such as using an Elytra.

Returns

TypeDescription
boolTrue if this actor is gliding.

methgetHealthabstractconst

int getHealth() const =0

Gets the entity's health from 0 to its max possible value, where 0 is dead.

Returns

TypeDescription
intHealth represented from 0 to max

methsetHealthabstractconst

void setHealth(int health) const =0

Sets the entity's health from 0 to its possible value, where 0 is dead.

Parameters

NameTypeDescription
healthintNew health represented from 0 to max

methgetMaxHealthabstractconst

int getMaxHealth() const =0

Gets the maximum health this entity has.

Returns

TypeDescription
intMaximum health

methsetMaxHealthabstractconst

void setMaxHealth(int health) const =0

Sets the maximum health this entity can have.

If the health of the entity is above the value provided, it will be set to that value.

Note

An entity with a health bar e.g., Player, EnderDragon, Wither, etc. will have their bar scaled accordingly.

Parameters

NameTypeDescription
healthintamount of health to set the maximum to

On this page