mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
Switch back to the old chunk-packet method since MoveEntityPacket and SetEntityMotionPacket no longer have lists
This commit is contained in:
parent
3c709b1d3e
commit
51a20470f6
@ -134,9 +134,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
/** @var Tile[] */
|
||||
private $tiles = [];
|
||||
|
||||
private $motionToSend = [];
|
||||
private $moveToSend = [];
|
||||
|
||||
/** @var Player[] */
|
||||
private $players = [];
|
||||
|
||||
@ -723,35 +720,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->checkSleep();
|
||||
}
|
||||
|
||||
foreach($this->moveToSend as $index => $entry){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
foreach($entry as $e){
|
||||
$pk = new MoveEntityPacket();
|
||||
$pk->eid = $e[0];
|
||||
$pk->x = $e[1];
|
||||
$pk->y = $e[2];
|
||||
$pk->z = $e[3];
|
||||
$pk->yaw = $e[4];
|
||||
$pk->headYaw = $e[5];
|
||||
$pk->pitch = $e[6];
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
}
|
||||
$this->moveToSend = [];
|
||||
|
||||
foreach($this->motionToSend as $index => $entry){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
foreach($entry as $entity){
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $entity[0];
|
||||
$pk->motionX = $entity[1];
|
||||
$pk->motionY = $entity[2];
|
||||
$pk->motionZ = $entity[3];
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
}
|
||||
$this->motionToSend = [];
|
||||
|
||||
foreach($this->chunkPackets as $index => $entries){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$chunkPlayers = $this->getChunkPlayers($chunkX, $chunkZ);
|
||||
@ -2827,16 +2795,23 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){
|
||||
if(!isset($this->motionToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){
|
||||
$this->motionToSend[$index] = [];
|
||||
}
|
||||
$this->motionToSend[$index][$entityId] = [$entityId, $x, $y, $z];
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $entityId;
|
||||
$pk->motionX = $x;
|
||||
$pk->motionY = $y;
|
||||
$pk->motionZ = $z;
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
|
||||
public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){
|
||||
if(!isset($this->moveToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){
|
||||
$this->moveToSend[$index] = [];
|
||||
}
|
||||
$this->moveToSend[$index][$entityId] = [$entityId, $x, $y, $z, $yaw, $headYaw === null ? $yaw : $headYaw, $pitch];
|
||||
$pk = new MoveEntityPacket();
|
||||
$pk->eid = $entityId;
|
||||
$pk->x = $x;
|
||||
$pk->y = $y;
|
||||
$pk->z = $z;
|
||||
$pk->yaw = $yaw;
|
||||
$pk->pitch = $pitch;
|
||||
$pk->headYaw = $headYaw ?? $yaw;
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user