mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
rewrite of entity save system
This commit is contained in:
parent
2bae9d8f42
commit
3af7ee98b4
8 changed files with 93 additions and 108 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue