endstone::Actor
Represents a base actor in the level.
Bases: endstone::CommandSender
Functions:
Name | Description |
---|---|
addScoreboardTag | Adds a tag to this actor. |
asItem | Gets an Actor as Item . |
asMob | Gets an Actor as Mob . |
getDimension | |
getHealth | Gets the entity’s health from 0 to its max possible value, where 0 is dead. |
getId | Returns a unique id for this actor. |
getLevel | |
getLocation | |
getMaxHealth | Gets the maximum health this entity has. |
getNameTag | Gets the current name tag of the actor. |
getRuntimeId | |
getScoreTag | Gets the current score tag of the actor. |
getScoreboardTags | Returns a list of scoreboard tags for this actor. |
getType | Get the type of the actor. |
getVelocity | |
isDead | Returns true if this actor has been marked for removal. |
isInLava | |
isInWater | |
isNameTagAlwaysVisible | Checks if the actor’s name tag is always visible. |
isNameTagVisible | Checks if the actor’s name tag is currently visible. |
isOnGround | |
isValid | |
remove | |
removeScoreboardTag | Removes a given tag from this actor. |
setHealth | |
setNameTag | Sets the name tag for the actor. |
setNameTagAlwaysVisible | Sets whether the actor’s name tag should always be visible. |
setNameTagVisible | Sets if the actor’s name tag is visible or not. |
setRotation | |
setScoreTag | Sets the score tag for the actor. |
teleport | |
teleport |
addScoreboardTag
bool addScoreboardTag(std::string tag) const
Adds a tag to this actor.
Parameters:
tag
the tag to add
Returns:
true if the tag was successfully added, false if the tag already exists.
asItem
Item *asItem() const
Gets an Actor as Item .
Returns:
asMob
Mob *asMob() const
Gets an Actor as Mob .
Returns:
getDimension
Dimension &getDimension() const
Gets the current Dimension this actor resides in
Returns:
The current Dimension this actor resides in
getHealth
int getHealth() const
Gets the entity’s health from 0 to its max possible value, where 0 is dead.
Returns:
Health represented from 0 to max
getId
std::int64_t getId() const
Returns a unique id for this actor.
Returns:
Actor id
getLevel
Level &getLevel() const
Gets the current Level this actor resides in
Returns:
The current Level this actor resides in
getLocation
Location getLocation() const
Gets the actor’s current position
Returns:
a new copy of Location containing the position of this actor
getMaxHealth
int getMaxHealth() const
Gets the maximum health this entity has.
Returns:
Maximum health
getNameTag
std::string getNameTag() const
Gets the current name tag of the actor.
Returns:
The name tag.
getRuntimeId
std::uint64_t getRuntimeId() const
Returns the runtime id for this actor
Returns:
Runtime id for this actor
getScoreTag
std::string getScoreTag() const
Gets the current score tag of the actor.
Returns:
The score tag.
getScoreboardTags
std::vector<std::string> getScoreboardTags() const
Returns a list of scoreboard tags for this actor.
Returns:
a list of scoreboard tags for this actor
getType
std::string getType() const
Get the type of the actor.
This method returns the type of the actor as a string, for example, minecraft:pig.
Returns:
The type of the actor.
getVelocity
Vector<float> getVelocity() const
Gets this actor’s current velocity
Returns:
Current traveling velocity of this actor
isDead
bool isDead() const
Returns true if this actor has been marked for removal.
Returns:
True if it is dead.
isInLava
bool isInLava() const
Returns true if the actor is in lava.
Returns:
True if the actor is in lava.
isInWater
bool isInWater() const
Returns true if the actor is in water.
Returns:
True if the actor is in water.
isNameTagAlwaysVisible
bool isNameTagAlwaysVisible() const
Checks if the actor’s name tag is always visible.
Returns:
True if the name tag is always visible, false otherwise.
isNameTagVisible
bool isNameTagVisible() const
Checks if the actor’s name tag is currently visible.
Returns:
True if the name tag is visible, false otherwise.
isOnGround
bool isOnGround() const
Returns true if the actor is supported by a block.
Returns:
True if actor is on ground.
isValid
bool isValid() const
Returns false if the entity has died, been despawned for some other reason, or has not been added to the level.
Returns:
True if valid.
remove
void remove()
Remove this actor from the level.
If you are trying to remove a Player, use Player::kick instead.
removeScoreboardTag
bool removeScoreboardTag(std::string tag) const
Removes a given tag from this actor.
Parameters:
tag
the tag to remove
Returns:
true if the tag was successfully removed, false if the tag does not exist.
setHealth
Result<void> setHealth(int health) const
Sets the entity’s health from 0 to its possible value, where 0 is dead.
Parameters:
health
New health represented from 0 to max
setNameTag
void setNameTag(std::string name)
Sets the name tag for the actor.
Parameters:
name
The new name tag to set.
setNameTagAlwaysVisible
void setNameTagAlwaysVisible(bool visible)
Sets whether the actor’s name tag should always be visible.
Parameters:
visible
True to make the name tag always visible, false to disable always visibility.
setNameTagVisible
void setNameTagVisible(bool visible)
Sets if the actor’s name tag is visible or not.
Parameters:
visible
True to make the name tag visible, false to hide it.
setRotation
void setRotation(float yaw, float pitch)
Returns:
Sets the actor’s rotation.
Note that if the actor is affected by AI, it may override this rotation.
Parameters:
yaw
Rotation around the up axis (Y axis)pitch
Rotation around the right axis (X axis)
setScoreTag
void setScoreTag(std::string score)
Sets the score tag for the actor.
Parameters:
score
The new score tag to set.
teleport
void teleport(Location location)
Returns:
Teleports this actor to the given location.
Parameters:
location
New location to teleport this actor to
void teleport(Actor &target)
Teleports this actor to the target Actor.
Parameters:
target
Actor to teleport this actor to