mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
fixed player spawn point
This commit is contained in:
parent
b4bf0dd0f7
commit
4fe79458ab
3 changed files with 78 additions and 26 deletions
|
|
@ -541,7 +541,13 @@ void WorldFiles::writePlayer(Player* player) {
|
|||
auto& rotarr = root.putList("rotation");
|
||||
rotarr.put(player->cam.x);
|
||||
rotarr.put(player->cam.y);
|
||||
|
||||
|
||||
auto& sparr = root.putList("spawnpoint");
|
||||
glm::vec3 spawnpoint = player->getSpawnPoint();
|
||||
sparr.put(spawnpoint.x);
|
||||
sparr.put(spawnpoint.y);
|
||||
sparr.put(spawnpoint.z);
|
||||
|
||||
root.put("flight", player->flight);
|
||||
root.put("noclip", player->noclip);
|
||||
root.put("chosen-slot", player->getChosenSlot());
|
||||
|
|
@ -569,6 +575,17 @@ bool WorldFiles::readPlayer(Player* player) {
|
|||
player->cam.x = rotarr->num(0);
|
||||
player->cam.y = rotarr->num(1);
|
||||
|
||||
if (root->has("spawnpoint")) {
|
||||
auto sparr = root->list("spawnpoint");
|
||||
player->setSpawnPoint(glm::vec3(
|
||||
sparr->num(0),
|
||||
sparr->num(1),
|
||||
sparr->num(2)
|
||||
));
|
||||
} else {
|
||||
player->setSpawnPoint(position);
|
||||
}
|
||||
|
||||
root->flag("flight", player->flight);
|
||||
root->flag("noclip", player->noclip);
|
||||
player->setChosenSlot(root->getInt("chosen-slot", player->getChosenSlot()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue