mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-17 19:50:18 +00:00
NetworkSession: allow sending an arbitrary set of attributes for an entity
This commit is contained in:
@@ -680,12 +680,14 @@ class NetworkSession{
|
||||
$this->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
public function syncAttributes(Living $entity, bool $sendAll = false) : void{
|
||||
$entries = $sendAll ? $entity->getAttributeMap()->getAll() : $entity->getAttributeMap()->needSend();
|
||||
if(count($entries) > 0){
|
||||
/**
|
||||
* @param Attribute[] $attributes
|
||||
*/
|
||||
public function syncAttributes(Living $entity, array $attributes) : void{
|
||||
if(count($attributes) > 0){
|
||||
$this->sendDataPacket(UpdateAttributesPacket::create($entity->getId(), array_map(function(Attribute $attr) : NetworkAttribute{
|
||||
return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue());
|
||||
}, $entries)));
|
||||
}, $attributes)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user