MCPcopy Create free account
hub / github.com/EndstoneMC/endstone / init_actor

Function init_actor

src/endstone/python/actor.cpp:21–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace endstone::python {
20
21void init_actor(py::module_ &m, py::class_<Actor, CommandSender> &actor, py::class_<Mob, Actor> &mob)
22{
23 actor.def_property_readonly("type", &Actor::getType, "Gets the type of the actor.")
24 .def_property_readonly("runtime_id", &Actor::getRuntimeId, "Returns the runtime id for this actor.")
25 .def_property_readonly("location", &Actor::getLocation, "Gets the actor's current position.")
26 .def_property_readonly("velocity", &Actor::getVelocity, "Gets this actor's current velocity.")
27 .def_property_readonly("is_on_ground", &Actor::isOnGround,
28 "Returns true if the actor is supported by a block, i.e. on ground.")
29 .def_property_readonly("is_in_water", &Actor::isInWater, "Returns true if the actor is in water.")
30 .def_property_readonly("is_in_lava", &Actor::isInLava, "Returns true if the actor is in lava.")
31 .def_property_readonly("level", &Actor::getLevel, "Gets the current Level this actor resides in.",
32 py::return_value_policy::reference)
33 .def_property_readonly("dimension", &Actor::getDimension, "Gets the current Dimension this actor resides in.",
34 py::return_value_policy::reference)
35 .def("set_rotation", &Actor::setRotation, "Sets the actor's rotation.", py::arg("yaw"), py::arg("pitch"))
36 .def("teleport", py::overload_cast<const Location &>(&Actor::teleport),
37 "Teleports this actor to the given location.", py::arg("location"))
38 .def("teleport", py::overload_cast<const Actor &>(&Actor::teleport),
39 "Teleports this actor to the target Actor.", py::arg("target"))
40 .def_property_readonly("id", &Actor::getId, "Returns a unique id for this actor.")
41 .def("remove", &Actor::remove, "Remove this actor from the level.")
42 .def_property_readonly("is_valid", &Actor::isValid,
43 "Returns false if the entity has died, been despawned for some other reason, or has not "
44 "been added to the level.")
45 .def_property_readonly("is_dead", &Actor::isDead, "Returns true if this actor has been marked for removal.")
46 .def_property_readonly("scoreboard_tags", &Actor::getScoreboardTags,
47 "Returns a list of scoreboard tags for this actor.")
48 .def("add_scoreboard_tag", &Actor::addScoreboardTag, "Adds a tag to this actor.", py::arg("tag"))
49 .def("remove_scoreboard_tag", &Actor::removeScoreboardTag, "Removes a given tag from this actor.",
50 py::arg("tag"))
51 .def_property("is_name_tag_visible", &Actor::isNameTagVisible, &Actor::setNameTagVisible,
52 "Gets or sets if the actor's name tag is visible or not.")
53 .def_property("is_name_tag_always_visible", &Actor::isNameTagAlwaysVisible, &Actor::setNameTagAlwaysVisible,
54 "Gets or sets if the actor's name tag is always visible or not.")
55 .def_property("name_tag", &Actor::getNameTag, &Actor::setNameTag,
56 "Gets or sets the current name tag of the actor.")
57 .def_property("score_tag", &Actor::getScoreTag, &Actor::setScoreTag,
58 "Gets or sets the current score tag of the actor.");
59
60 mob.def_property_readonly("is_gliding", &Mob::isGliding,
61 "Checks to see if an actor is gliding, such as using an Elytra.")
62 .def_property("health", &Mob::getHealth, &Mob::setHealth,
63 "Gets or sets the entity's health from 0 to its max possible value, where 0 is dead.")
64 .def_property("max_health", &Mob::getMaxHealth, &Mob::setMaxHealth,
65 "Gets or sets the maximum health this entity has.");
66
67 py::class_<Item, Actor>(m, "Item", "Represents a base actor in the level.")
68 .def_property("item_stack", &Item::getItemStack, &Item::setItemStack,
69 "Gets or sets the item stack associated with this item drop.")
70 .def_property("pickup_delay", &Item::getPickupDelay, &Item::setPickupDelay,
71 "Gets or sets the delay before this Item is available to be picked up by players.")
72 .def_property("is_unlimited_lifetime", &Item::isUnlimitedLifetime, &Item::setUnlimitedLifetime,
73 "Gets or sets if this Item lives forever")
74 .def_property("thrower", &Item::getThrower, &Item::setThrower, "Gets or sets the thrower of this item.");
75}
76
77} // namespace endstone::python

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected