mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add ENTITY_NONE, ENTITY_AUTO reserved entity id & update player.set_entity(...)
This commit is contained in:
parent
f2101f6504
commit
23c66654a2
4 changed files with 7 additions and 4 deletions
|
|
@ -62,7 +62,7 @@ Player::Player(
|
|||
Player::~Player() = default;
|
||||
|
||||
void Player::updateEntity() {
|
||||
if (eid == 0) {
|
||||
if (eid == ENTITY_AUTO) {
|
||||
auto& def = level.content.entities.require("base:player");
|
||||
eid = level.entities->spawn(def, getPosition());
|
||||
if (auto entity = level.entities->get(eid)) {
|
||||
|
|
@ -73,7 +73,7 @@ void Player::updateEntity() {
|
|||
if (auto entity = level.entities->get(eid)) {
|
||||
entity->setPlayer(id);
|
||||
}
|
||||
} else if (chunks->getChunkByVoxel(position)) {
|
||||
} else if (chunks->getChunkByVoxel(position) && eid != ENTITY_NONE) {
|
||||
logger.error() << "player entity despawned or deleted; "
|
||||
"will be respawned";
|
||||
eid = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue