mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
Entity: split getSyncedNetworkData() into two functions
to avoid opaque boolean parameters
This commit is contained in:
parent
e53b57732b
commit
053a7a1a61
@ -589,7 +589,7 @@ abstract class Entity{
|
||||
}
|
||||
}
|
||||
|
||||
$changedProperties = $this->getSyncedNetworkData(true);
|
||||
$changedProperties = $this->getDirtyNetworkData();
|
||||
if(count($changedProperties) > 0){
|
||||
$this->sendData(null, $changedProperties);
|
||||
$this->networkProperties->clearDirtyProperties();
|
||||
@ -1436,7 +1436,7 @@ abstract class Entity{
|
||||
$pk->attributes = array_map(function(Attribute $attr) : NetworkAttribute{
|
||||
return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue());
|
||||
}, $this->attributeMap->getAll());
|
||||
$pk->metadata = $this->getSyncedNetworkData(false);
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
}
|
||||
@ -1557,7 +1557,7 @@ abstract class Entity{
|
||||
*/
|
||||
public function sendData(?array $targets, ?array $data = null) : void{
|
||||
$targets = $targets ?? $this->hasSpawned;
|
||||
$data = $data ?? $this->getSyncedNetworkData(false);
|
||||
$data = $data ?? $this->getAllNetworkData();
|
||||
|
||||
foreach($targets as $p){
|
||||
$p->getNetworkSession()->syncActorData($this, $data);
|
||||
@ -1568,10 +1568,18 @@ abstract class Entity{
|
||||
* @return MetadataProperty[]
|
||||
* @phpstan-return array<int, MetadataProperty>
|
||||
*/
|
||||
final protected function getSyncedNetworkData(bool $dirtyOnly) : array{
|
||||
final protected function getDirtyNetworkData() : array{
|
||||
$this->syncNetworkData($this->networkProperties);
|
||||
return $this->networkProperties->getDirty();
|
||||
}
|
||||
|
||||
return $dirtyOnly ? $this->networkProperties->getDirty() : $this->networkProperties->getAll();
|
||||
/**
|
||||
* @return MetadataProperty[]
|
||||
* @phpstan-return array<int, MetadataProperty>
|
||||
*/
|
||||
final protected function getAllNetworkData() : array{
|
||||
$this->syncNetworkData($this->networkProperties);
|
||||
return $this->networkProperties->getAll();
|
||||
}
|
||||
|
||||
protected function syncNetworkData(EntityMetadataCollection $properties) : void{
|
||||
|
@ -399,7 +399,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
$pk->yaw = $this->location->yaw;
|
||||
$pk->pitch = $this->location->pitch;
|
||||
$pk->item = TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand());
|
||||
$pk->metadata = $this->getSyncedNetworkData(false);
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
|
||||
//TODO: Hack for MCPE 1.2.13: DATA_NAMETAG is useless in AddPlayerPacket, so it has to be sent separately
|
||||
|
@ -210,7 +210,7 @@ class ItemEntity extends Entity{
|
||||
$pk->position = $this->location->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->item = TypeConverter::getInstance()->coreItemStackToNet($this->getItem());
|
||||
$pk->metadata = $this->getSyncedNetworkData(false);
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user