Skip to content

Commit

Permalink
feat: add python bindings for newly added APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Dec 23, 2024
1 parent d3979e1 commit 2ec06ff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/endstone/actor/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ class Actor : public CommandSender {
[[nodiscard]] virtual bool removeScoreboardTag(std::string tag) const = 0;

/**
* @brief Checks if the name tag is currently visible.
* @brief Checks if the actor's name tag is currently visible.
*
* @return True if the name tag is visible, false otherwise.
*/
[[nodiscard]] virtual bool isNameTagVisible() const = 0;

/**
* @brief Sets whether the name tag is visible or not.
* @brief Sets if the actor's name tag is visible or not.
*
* @param visible True to make the name tag visible, false to hide it.
*/
Expand Down
25 changes: 25 additions & 0 deletions python/src/endstone/_internal/endstone_python.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ class Actor(CommandSender):
Returns true if the actor is in water.
"""
@property
def is_nametag_visible(self) -> bool:
"""
Gets or sets if the actor's name tag is visible or not.
"""
@is_nametag_visible.setter
def is_nametag_visible(self, arg1: bool) -> None:
...
@property
def is_on_ground(self) -> bool:
"""
Returns true if the actor is supported by a block, i.e. on ground.
Expand All @@ -165,11 +173,27 @@ class Actor(CommandSender):
Gets the maximum health this entity has.
"""
@property
def name_tag(self) -> str:
"""
Gets or sets the current name tag of the actor.
"""
@name_tag.setter
def name_tag(self, arg1: str) -> None:
...
@property
def runtime_id(self) -> int:
"""
Returns the runtime id for this actor.
"""
@property
def score_tag(self) -> str:
"""
Gets or sets the current score tag of the actor.
"""
@score_tag.setter
def score_tag(self, arg1: str) -> None:
...
@property
def scoreboard_tags(self) -> list[str]:
"""
Returns a list of scoreboard tags for this actor.
Expand Down Expand Up @@ -676,6 +700,7 @@ class ColorFormat:
MATERIAL_NETHERITE: typing.ClassVar[str] = '§j'
MATERIAL_QUARTZ: typing.ClassVar[str] = '§h'
MATERIAL_REDSTONE: typing.ClassVar[str] = '§m'
MATERIAL_RESIN: typing.ClassVar[str] = '§v'
MINECOIN_GOLD: typing.ClassVar[str] = '§g'
OBFUSCATED: typing.ClassVar[str] = '§k'
RED: typing.ClassVar[str] = '§c'
Expand Down
8 changes: 7 additions & 1 deletion src/endstone_python/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ void init_actor(py::module_ &m, py::class_<Actor, CommandSender> &actor, py::cla
"Returns a list of scoreboard tags for this actor.")
.def("add_scoreboard_tag", &Actor::addScoreboardTag, "Adds a tag to this actor.", py::arg("tag"))
.def("remove_scoreboard_tag", &Actor::removeScoreboardTag, "Removes a given tag from this actor.",
py::arg("tag"));
py::arg("tag"))
.def_property("is_nametag_visible", &Actor::isNameTagVisible, &Actor::setNameTagVisible,
"Gets or sets if the actor's name tag is visible or not.")
.def_property("name_tag", &Actor::getNameTag, &Actor::setNameTag,
"Gets or sets the current name tag of the actor.")
.def_property("score_tag", &Actor::getScoreTag, &Actor::setScoreTag,
"Gets or sets the current score tag of the actor.");

mob.def_property_readonly("is_gliding", &Mob::isGliding,
"Checks to see if an actor is gliding, such as using an Elytra.");
Expand Down

0 comments on commit 2ec06ff

Please sign in to comment.