mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
NetworkSession: incomplete abstraction of SetActorDataPacket handling
this needs to have the metadata properties separated too, but that's a job that's going to get VERY messy.
This commit is contained in:
parent
d1b28ce17a
commit
4ce6525065
@ -48,7 +48,6 @@ use pocketmine\network\mcpe\protocol\AddActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\Attribute as NetworkAttribute;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
||||
@ -1647,17 +1646,18 @@ abstract class Entity{
|
||||
$player = [$player];
|
||||
}
|
||||
|
||||
$pk = SetActorDataPacket::create($this->getId(), $data ?? $this->getSyncedNetworkData(false));
|
||||
$data = $data ?? $this->getSyncedNetworkData(false);
|
||||
|
||||
foreach($player as $p){
|
||||
if($p === $this){
|
||||
continue;
|
||||
}
|
||||
$p->getNetworkSession()->sendDataPacket(clone $pk);
|
||||
$p->getNetworkSession()->syncActorData($this, $data);
|
||||
}
|
||||
|
||||
if($this instanceof Player){
|
||||
$this->getNetworkSession()->sendDataPacket($pk);
|
||||
//TODO: bad hack, remove
|
||||
$this->getNetworkSession()->syncActorData($this, $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
|
||||
use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
@ -80,6 +81,7 @@ use pocketmine\network\mcpe\protocol\types\command\CommandData;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandParameter;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\Attribute as NetworkAttribute;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
@ -691,6 +693,14 @@ class NetworkSession{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MetadataProperty[] $properties
|
||||
* @phpstan-param array<int, MetadataProperty> $properties
|
||||
*/
|
||||
public function syncActorData(Entity $entity, array $properties) : void{
|
||||
$this->sendDataPacket(SetActorDataPacket::create($entity->getId(), $properties));
|
||||
}
|
||||
|
||||
public function onEntityEffectAdded(Living $entity, EffectInstance $effect, bool $replacesOldEffect) : void{
|
||||
$this->sendDataPacket(MobEffectPacket::add($entity->getId(), $replacesOldEffect, $effect->getId(), $effect->getAmplifier(), $effect->isVisible(), $effect->getDuration()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user