mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
Players now saved yaw and pitch, and spawned in float pos
Also fixed /despawn
This commit is contained in:
parent
b47369414e
commit
f40fe179c1
2 changed files with 10 additions and 14 deletions
|
|
@ -102,7 +102,7 @@ class EntityAPI{
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
if($args[0] === "all"){
|
if($args[0] === "all"){
|
||||||
$l = $this->server->query("SELECT EID FROM entities WHERE class = 2 and 3 and 4 and 5;");
|
$l = $this->server->query("SELECT EID FROM entities WHERE class = 2 or 3 or 4 or 5;");
|
||||||
}else{
|
}else{
|
||||||
$array = explode(",", strtolower($args[0]));
|
$array = explode(",", strtolower($args[0]));
|
||||||
if(count($array) > 4){
|
if(count($array) > 4){
|
||||||
|
|
@ -113,9 +113,9 @@ class EntityAPI{
|
||||||
$list = "";
|
$list = "";
|
||||||
$temp = ["mobs" => "2", "objects" => "3", "items" => "4", "fallings" => "5"];
|
$temp = ["mobs" => "2", "objects" => "3", "items" => "4", "fallings" => "5"];
|
||||||
foreach($array as $value){
|
foreach($array as $value){
|
||||||
$list .= $temp[$value]." and ";
|
$list .= $temp[$value]." or ";
|
||||||
}
|
}
|
||||||
$despawning = substr($list, 0, -5);
|
$despawning = substr($list, 0, -4);
|
||||||
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".$despawning.";");
|
$l = $this->server->query("SELECT EID FROM entities WHERE class = ".$despawning.";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1203,14 +1203,16 @@ class Player{
|
||||||
$this->data->set("position", [
|
$this->data->set("position", [
|
||||||
"level" => $this->entity->level->getName(),
|
"level" => $this->entity->level->getName(),
|
||||||
"x" => (float) $this->entity->x,
|
"x" => (float) $this->entity->x,
|
||||||
"y" => $this->entity->y,
|
"y" => (float) $this->entity->y,
|
||||||
"z" => (float) $this->entity->z,
|
"z" => (float) $this->entity->z,
|
||||||
|
"yaw" => (float) $this->entity->yaw,
|
||||||
|
"pitch" => (float) $this->entity->pitch
|
||||||
]);
|
]);
|
||||||
$this->data->set("spawn", [
|
$this->data->set("spawn", [
|
||||||
"level" => $this->spawnPosition->level->getName(),
|
"level" => $this->spawnPosition->level->getName(),
|
||||||
"x" => $this->spawnPosition->x,
|
"x" => $this->spawnPosition->x,
|
||||||
"y" => $this->spawnPosition->y,
|
"y" => $this->spawnPosition->y,
|
||||||
"z" => $this->spawnPosition->z,
|
"z" => $this->spawnPosition->z
|
||||||
]);
|
]);
|
||||||
$inv = [];
|
$inv = [];
|
||||||
foreach($this->inventory as $slot => $item){
|
foreach($this->inventory as $slot => $item){
|
||||||
|
|
@ -1464,6 +1466,8 @@ class Player{
|
||||||
if($this->spawned !== false){
|
if($this->spawned !== false){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$pos = new Position($this->entity->x, $this->entity->y, $this->entity->z, $this->level);
|
||||||
|
$this->teleport($pos, $this->data->get("position")["yaw"], $this->data->get("position")["pitch"], true, true);
|
||||||
$this->entity->setHealth($this->data->get("health"), "spawn", true);
|
$this->entity->setHealth($this->data->get("health"), "spawn", true);
|
||||||
$this->spawned = true;
|
$this->spawned = true;
|
||||||
$this->server->api->player->spawnAllPlayers($this);
|
$this->server->api->player->spawnAllPlayers($this);
|
||||||
|
|
@ -1487,13 +1491,6 @@ class Player{
|
||||||
$pk = new SetTimePacket;
|
$pk = new SetTimePacket;
|
||||||
$pk->time = $this->level->getTime();
|
$pk->time = $this->level->getTime();
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
$pos = new Position(floor($this->data->get("position")["x"]), floor($this->data->get("position")["y"]), floor($this->data->get("position")["z"]), $this->level);
|
|
||||||
$pos = $this->level->getSafeSpawn($pos);
|
|
||||||
$this->teleport($pos, false, false, true, true);
|
|
||||||
|
|
||||||
$this->server->schedule(10, [$this, "teleport"], $pos);
|
|
||||||
$this->server->schedule(20, [$this, "teleport"], $pos);
|
|
||||||
$this->server->schedule(30, [$this, "teleport"], $pos);
|
|
||||||
$this->server->handle("player.spawn", $this);
|
$this->server->handle("player.spawn", $this);
|
||||||
break;
|
break;
|
||||||
case 2://Chunk loaded?
|
case 2://Chunk loaded?
|
||||||
|
|
@ -1864,7 +1861,6 @@ class Player{
|
||||||
];
|
];
|
||||||
$slot = $this->getSlot($this->slot);
|
$slot = $this->getSlot($this->slot);
|
||||||
if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){
|
if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){
|
||||||
|
|
||||||
$pk = new EntityEventPacket;
|
$pk = new EntityEventPacket;
|
||||||
$pk->eid = 0;
|
$pk->eid = 0;
|
||||||
$pk->event = 9;
|
$pk->event = 9;
|
||||||
|
|
@ -2051,7 +2047,7 @@ class Player{
|
||||||
"offset" => $offset,
|
"offset" => $offset,
|
||||||
"slotdata" => $slot,
|
"slotdata" => $slot,
|
||||||
"itemdata" => $item,
|
"itemdata" => $item,
|
||||||
"player" => $this,
|
"player" => $this
|
||||||
]) === false){
|
]) === false){
|
||||||
$pk = new ContainerSetSlotPacket;
|
$pk = new ContainerSetSlotPacket;
|
||||||
$pk->windowid = $packet->windowid;
|
$pk->windowid = $packet->windowid;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue