endstone/actor
Classes
classActor
Defined in <endstone/actor/actor.h>
Bases: CommandSender
Represents a base actor in the level.
Methods
| Name | Description |
|---|---|
asMob | Gets an Actor as Mob. |
asItem | Gets an Actor as Item. |
getType | Get the type of the actor. |
getRuntimeId | |
getLocation | |
getVelocity | |
isOnGround | |
isInWater | |
isInLava | |
getLevel | |
getDimension | |
setRotation | |
teleport | |
teleport | |
getId | Returns a unique id for this actor. |
remove | |
isDead | Returns true if this actor has been marked for removal. |
isValid | |
getScoreboardTags | Returns a list of scoreboard tags for this actor. |
addScoreboardTag | Adds a tag to this actor. |
removeScoreboardTag | Removes a given tag from this actor. |
isNameTagVisible | Checks if the actor's name tag is currently visible. |
setNameTagVisible | Sets if the actor's name tag is visible or not. |
isNameTagAlwaysVisible | Checks if the actor's name tag is always visible. |
setNameTagAlwaysVisible | Sets whether the actor's name tag should always be visible. |
getNameTag | Gets the current name tag of the actor. |
setNameTag | Sets the name tag for the actor. |
getScoreTag | Gets the current score tag of the actor. |
setScoreTag | Sets the score tag for the actor. |
methasMobabstractconst
Mob* asMob() const =0methasItemabstractconst
Item* asItem() const =0methgetTypeabstractconst
std::string getType() const =0Get the type of the actor.
This method returns the type of the actor as a string, for example, minecraft:pig.
Returns
| Type | Description |
|---|---|
std::string | The type of the actor. |
methgetRuntimeIdabstractconst
std::uint64_t getRuntimeId() const =0Returns the runtime id for this actor
Returns
| Type | Description |
|---|---|
std::uint64_t | Runtime id for this actor |
methgetLocationabstractconst
Location getLocation() const =0Gets the actor's current position
methgetVelocityabstractconst
Vector getVelocity() const =0Gets this actor's current velocity
Returns
| Type | Description |
|---|---|
Vector | Current traveling velocity of this actor |
methisOnGroundabstractconst
bool isOnGround() const =0Returns true if the actor is supported by a block.
Returns
| Type | Description |
|---|---|
bool | True if actor is on ground. |
methisInWaterabstractconst
bool isInWater() const =0Returns true if the actor is in water.
Returns
| Type | Description |
|---|---|
bool | True if the actor is in water. |
methisInLavaabstractconst
bool isInLava() const =0Returns true if the actor is in lava.
Returns
| Type | Description |
|---|---|
bool | True if the actor is in lava. |
methgetLevelabstractconst
Level& getLevel() const =0Gets the current Level this actor resides in
methgetDimensionabstractconst
Dimension& getDimension() const =0Gets the current Dimension this actor resides in
methsetRotationabstract
void setRotation(float yaw, float pitch) =0Note that if the actor is affected by AI, it may override this rotation.
Parameters
| Name | Type | Description |
|---|---|---|
yaw | float | Rotation around the up axis (Y axis) |
pitch | float | Rotation around the right axis (X axis) |
Returns
| Type | Description |
|---|---|
void | Sets the actor's rotation. |
methteleportabstract
bool teleport(const Location& location) =0Parameters
| Name | Type | Description |
|---|---|---|
location | const Location& | New location to teleport this actor to |
Returns
| Type | Description |
|---|---|
bool | Teleports this actor to the given location. |
methteleportabstract
bool teleport(const Actor& target) =0Teleports this actor to the target Actor.
methgetIdabstractconst
std::int64_t getId() const =0Returns a unique id for this actor.
Returns
| Type | Description |
|---|---|
std::int64_t | Actor id |
methremoveabstract
void remove() =0Remove this actor from the level.
If you are trying to remove a Player, use Player::kick instead.
methisDeadabstractconst
bool isDead() const =0Returns true if this actor has been marked for removal.
Returns
| Type | Description |
|---|---|
bool | True if it is dead. |
methisValidabstractconst
bool isValid() const =0Returns false if the entity has died, been despawned for some other reason, or has not been added to the level.
Returns
| Type | Description |
|---|---|
bool | True if valid. |
methgetScoreboardTagsabstractconst
std::vector<std::string> getScoreboardTags() const =0Returns a list of scoreboard tags for this actor.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | a list of scoreboard tags for this actor |
methaddScoreboardTagabstractconst
bool addScoreboardTag(std::string tag) const =0Adds a tag to this actor.
Parameters
| Name | Type | Description |
|---|---|---|
tag | std::string | the tag to add |
Returns
| Type | Description |
|---|---|
bool | true if the tag was successfully added, false if the tag already exists. |
methremoveScoreboardTagabstractconst
bool removeScoreboardTag(std::string tag) const =0Removes a given tag from this actor.
Parameters
| Name | Type | Description |
|---|---|---|
tag | std::string | the tag to remove |
Returns
| Type | Description |
|---|---|
bool | true if the tag was successfully removed, false if the tag does not exist. |
methisNameTagVisibleabstractconst
bool isNameTagVisible() const =0Checks if the actor's name tag is currently visible.
Returns
| Type | Description |
|---|---|
bool | True if the name tag is visible, false otherwise. |
methsetNameTagVisibleabstract
void setNameTagVisible(bool visible) =0Sets if the actor's name tag is visible or not.
Parameters
| Name | Type | Description |
|---|---|---|
visible | bool | True to make the name tag visible, false to hide it. |
methisNameTagAlwaysVisibleabstractconst
bool isNameTagAlwaysVisible() const =0Checks if the actor's name tag is always visible.
Returns
| Type | Description |
|---|---|
bool | True if the name tag is always visible, false otherwise. |
methsetNameTagAlwaysVisibleabstract
void setNameTagAlwaysVisible(bool visible) =0Sets whether the actor's name tag should always be visible.
Parameters
| Name | Type | Description |
|---|---|---|
visible | bool | True to make the name tag always visible, false to disable always visibility. |
methgetNameTagabstractconst
std::string getNameTag() const =0Gets the current name tag of the actor.
Returns
| Type | Description |
|---|---|
std::string | The name tag. |
methsetNameTagabstract
void setNameTag(std::string name) =0Sets the name tag for the actor.
Parameters
| Name | Type | Description |
|---|---|---|
name | std::string | The new name tag to set. |
methgetScoreTagabstractconst
std::string getScoreTag() const =0Gets the current score tag of the actor.
Returns
| Type | Description |
|---|---|
std::string | The score tag. |
methsetScoreTagabstract
void setScoreTag(std::string score) =0Sets the score tag for the actor.
Parameters
| Name | Type | Description |
|---|---|---|
score | std::string | The new score tag to set. |
classItem
Defined in <endstone/actor/item.h>
Bases: Actor
Represents a base actor in the level.
Methods
| Name | Description |
|---|---|
getItemStack | Gets the item stack associated with this item drop. |
setItemStack | Sets the item stack associated with this item drop. |
getPickupDelay | Gets the delay before this Item is available to be picked up by players. |
setPickupDelay | Sets the delay before this Item is available to be picked up by players. |
setUnlimitedLifetime | Sets if this Item should live forever. |
isUnlimitedLifetime | Gets if this Item lives forever. |
setThrower | Set the thrower of this item. |
getThrower | Get the thrower of this item. |
methgetItemStackabstractconst
ItemStack getItemStack() const =0Gets the item stack associated with this item drop.
Returns
| Type | Description |
|---|---|
ItemStack | An item stack. |
methsetItemStackabstract
void setItemStack(const ItemStack& stack) =0Sets the item stack associated with this item drop.
Parameters
| Name | Type | Description |
|---|---|---|
stack | const ItemStack& | An item stack. |
methgetPickupDelayabstractconst
int getPickupDelay() const =0Gets the delay before this Item is available to be picked up by players.
Returns
| Type | Description |
|---|---|
int | Remaining delay |
methsetPickupDelayabstract
void setPickupDelay(int delay) =0Sets the delay before this Item is available to be picked up by players.
Parameters
| Name | Type | Description |
|---|---|---|
delay | int | New delay |
methsetUnlimitedLifetimeabstract
void setUnlimitedLifetime(bool unlimited) =0Sets if this Item should live forever.
Parameters
| Name | Type | Description |
|---|---|---|
unlimited | bool | true if the lifetime is unlimited |
methisUnlimitedLifetimeabstractconst
bool isUnlimitedLifetime() const =0Gets if this Item lives forever.
Returns
| Type | Description |
|---|---|
bool | true if the lifetime is unlimited |
methsetThrowerabstract
void setThrower(std::optional<std::int64_t> thrower) =0Set the thrower of this item.
Note
The thrower is the entity which dropped the item.
Parameters
| Name | Type | Description |
|---|---|---|
thrower | std::optional<std::int64_t> | unique id of thrower |
methgetThrowerabstractconst
std::optional<std::int64_t> getThrower() const =0Get the thrower of this item.
Note
The thrower is the entity which dropped the item.
Returns
| Type | Description |
|---|---|
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
| Name | Description |
|---|---|
isGliding | Checks to see if an actor is gliding, such as using an Elytra. |
getHealth | Gets the entity's health from 0 to its max possible value, where 0 is dead. |
setHealth | |
getMaxHealth | Gets the maximum health this entity has. |
setMaxHealth | Sets the maximum health this entity can have. |
methisGlidingabstractconst
bool isGliding() const =0Checks to see if an actor is gliding, such as using an Elytra.
Returns
| Type | Description |
|---|---|
bool | True if this actor is gliding. |
methgetHealthabstractconst
int getHealth() const =0Gets the entity's health from 0 to its max possible value, where 0 is dead.
Returns
| Type | Description |
|---|---|
int | Health represented from 0 to max |
methsetHealthabstractconst
void setHealth(int health) const =0Sets the entity's health from 0 to its possible value, where 0 is dead.
Parameters
| Name | Type | Description |
|---|---|---|
health | int | New health represented from 0 to max |
methgetMaxHealthabstractconst
int getMaxHealth() const =0Gets the maximum health this entity has.
Returns
| Type | Description |
|---|---|
int | Maximum health |
methsetMaxHealthabstractconst
void setMaxHealth(int health) const =0Sets 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
| Name | Type | Description |
|---|---|---|
health | int | amount of health to set the maximum to |