mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +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;
|
||||
}else{
|
||||
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{
|
||||
$array = explode(",", strtolower($args[0]));
|
||||
if(count($array) > 4){
|
||||
|
|
@ -113,9 +113,9 @@ class EntityAPI{
|
|||
$list = "";
|
||||
$temp = ["mobs" => "2", "objects" => "3", "items" => "4", "fallings" => "5"];
|
||||
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.";");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1203,14 +1203,16 @@ class Player{
|
|||
$this->data->set("position", [
|
||||
"level" => $this->entity->level->getName(),
|
||||
"x" => (float) $this->entity->x,
|
||||
"y" => $this->entity->y,
|
||||
"y" => (float) $this->entity->y,
|
||||
"z" => (float) $this->entity->z,
|
||||
"yaw" => (float) $this->entity->yaw,
|
||||
"pitch" => (float) $this->entity->pitch
|
||||
]);
|
||||
$this->data->set("spawn", [
|
||||
"level" => $this->spawnPosition->level->getName(),
|
||||
"x" => $this->spawnPosition->x,
|
||||
"y" => $this->spawnPosition->y,
|
||||
"z" => $this->spawnPosition->z,
|
||||
"z" => $this->spawnPosition->z
|
||||
]);
|
||||
$inv = [];
|
||||
foreach($this->inventory as $slot => $item){
|
||||
|
|
@ -1464,6 +1466,8 @@ class Player{
|
|||
if($this->spawned !== false){
|
||||
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->spawned = true;
|
||||
$this->server->api->player->spawnAllPlayers($this);
|
||||
|
|
@ -1487,13 +1491,6 @@ class Player{
|
|||
$pk = new SetTimePacket;
|
||||
$pk->time = $this->level->getTime();
|
||||
$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);
|
||||
break;
|
||||
case 2://Chunk loaded?
|
||||
|
|
@ -1864,7 +1861,6 @@ class Player{
|
|||
];
|
||||
$slot = $this->getSlot($this->slot);
|
||||
if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){
|
||||
|
||||
$pk = new EntityEventPacket;
|
||||
$pk->eid = 0;
|
||||
$pk->event = 9;
|
||||
|
|
@ -2051,7 +2047,7 @@ class Player{
|
|||
"offset" => $offset,
|
||||
"slotdata" => $slot,
|
||||
"itemdata" => $item,
|
||||
"player" => $this,
|
||||
"player" => $this
|
||||
]) === false){
|
||||
$pk = new ContainerSetSlotPacket;
|
||||
$pk->windowid = $packet->windowid;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue