#include <Player.h>
◆ getId()
| virtual const std::string & lodestone::level::entity::Player::getId |
( |
| ) |
const |
|
pure virtual |
Can return a UUID, player name, or other depending on the version.
◆ getLevel()
| Level * lodestone::level::entity::Player::getLevel |
( |
| ) |
const |
level::Level * m_currentLevel
Definition Player.h:54
◆ getProperty()
◆ getType()
◆ getWorld()
| world::World * lodestone::level::entity::Player::getWorld |
( |
| ) |
const |
world::World * m_world
Definition Player.h:53
◆ isInLevel()
| bool lodestone::level::entity::Player::isInLevel |
( |
| ) |
const |
level::Level * getLevel() const
Definition Player.cpp:50
◆ isInWorld()
| bool lodestone::level::entity::Player::isInWorld |
( |
| ) |
const |
world::World * getWorld() const
Definition Player.cpp:10
◆ isOnGround()
| bool lodestone::level::entity::Player::isOnGround |
( |
| ) |
const |
70 {
72 if (lvl == nullptr)
73 return false;
74
75 double t;
76
77
78
79
80
81
82
83 if (std::modf(this->
position.y, &t) == 0 &&
84 lvl->getBlock(this->position.x, this->position.y - 1,
85 this->position.z)
86 .getBlock()->hasCollision())
87 return true;
88
89 return false;
90 }
types::Vec3d position
Definition WorldSpaceObject.h:20
◆ respawn()
| void lodestone::level::entity::Player::respawn |
( |
bool | inDefaultLevel = true | ) |
|
|
virtual |
54 {
56
57 if (
const world::World *wld =
getWorld();
60 static_cast<types::Vec3d>(wld->getDefaultLevel()->getSpawnPos());
61 }
else if (
const Level *lvl = this->
getLevel(); lvl !=
nullptr) {
63 } else {
65 }
66
68 }
virtual int getMaxHealth() const
Definition Entity.cpp:17
void resetCoords()
Definition Entity.cpp:31
int m_health
Definition Entity.h:56
virtual Level * getDefaultLevel() const
Definition World.cpp:46
Vec3< double > Vec3d
Definition Vec3.h:177
◆ setLevel()
| void lodestone::level::entity::Player::setLevel |
( |
level::Level * | level, |
|
|
bool | resetCoords = true ) |
|
protected |
Sets the player's level.
NOTE: if the level is contained within a different world, the player will be moved to that world.
14 {
15 if (!level)
16 throw std::runtime_error(
17 "Attempted to move player into null level");
18
21
22 this->
m_world = level->getWorld();
23
26 }
27 }
28 }
◆ setWorld()
| void lodestone::level::entity::Player::setWorld |
( |
world::World * | world, |
|
|
bool | resetCoords = true ) |
|
protected |
Sets the player's world.
NOTE: if the current level does not exist within the given world, the player will be moved to the default level.
30 {
31 if (!world)
32 throw std::runtime_error(
33 "Attempted to move player into null world");
34
36
42 }
43 }
44 }
◆ toString()
| std::string lodestone::level::entity::Player::toString |
( |
| ) |
const |
|
inlineoverridevirtual |
Reimplemented from lodestone::level::entity::Entity.
19 {
20 return std::format(
"Player[id={}, health={}, pos={}]", this->
getId(), this->
m_health, this->
position.toString());
21 };
virtual const std::string & getId() const =0
Can return a UUID, player name, or other depending on the version.
◆ lodestone::level::world::World
◆ m_currentLevel
| level::Level* lodestone::level::entity::Player::m_currentLevel = nullptr |
|
private |
◆ m_world
| world::World* lodestone::level::entity::Player::m_world = nullptr |
|
private |
The documentation for this class was generated from the following files:
- /home/runner/work/libLodestone/libLodestone/projects/Libraries/Level/include/Lodestone.Level/entity/Player.h
- /home/runner/work/libLodestone/libLodestone/projects/Libraries/Level/src/entity/Player.cpp