rewrite of entity save system

This commit is contained in:
GameHerobrine 2022-11-13 01:53:06 +03:00
parent 2bae9d8f42
commit 3af7ee98b4
8 changed files with 93 additions and 108 deletions

View file

@ -88,93 +88,7 @@ class Level{
if($extra !== false){
$entities = [];
foreach($this->server->api->entity->getAll($this) as $entity){
if($entity->class === ENTITY_MOB){
$entities[] = [
"id" => $entity->type,
"Color" => @$entity->data["Color"],
"Sheared" => @$entity->data["Sheared"],
"State" => @$entity->data["State"],
"IsBaby" => @$entity->data["IsBaby"],
"Health" => $entity->health,
"Pos" => [
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
],
"Rotation" => [
0 => $entity->yaw,
1 => $entity->pitch,
],
];
}elseif($entity->class === ENTITY_OBJECT){
if($entity->type === OBJECT_PAINTING){
$entities[] = [
"id" => $entity->type,
"TileX" => $entity->x,
"TileY" => $entity->y,
"TileZ" => $entity->z,
"Health" => $entity->health,
"Motive" => $entity->data["Motive"],
"Pos" => [
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
],
"Rotation" => [
0 => $entity->yaw,
1 => $entity->pitch,
],
];
}else{
$entities[] = [
"id" => $entity->type,
"Health" => $entity->health,
"Pos" => [
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
],
"Rotation" => [
0 => $entity->yaw,
1 => $entity->pitch,
],
];
}
}elseif($entity->class === ENTITY_FALLING){
$entities[] = [
"id" => $entity->type,
"Health" => $entity->health,
"Tile" => $entity->data["Tile"],
"Pos" => [
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
],
"Rotation" => [
0 => 0,
1 => 0,
],
];
}elseif($entity->class === ENTITY_ITEM){
$entities[] = [
"id" => 64,
"Item" => [
"id" => $entity->type,
"Damage" => $entity->meta,
"Count" => $entity->stack,
],
"Health" => $entity->health,
"Pos" => [
0 => $entity->x,
1 => $entity->y,
2 => $entity->z,
],
"Rotation" => [
0 => 0,
1 => 0,
],
];
}
$entities[] = $entity->createSaveData();
}
$this->entities->setAll($entities);
$this->entities->save();