box up TakeItemActorPacket sending behind NetworkSession API

we need to start thinking about moving this into interfaces.
This commit is contained in:
Dylan K. Taylor
2020-04-29 16:24:04 +01:00
parent 1122f2a29f
commit d8968e9e40
3 changed files with 12 additions and 4 deletions

View File

@@ -31,7 +31,6 @@ use pocketmine\item\Item;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\convert\TypeConverter;
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds;
use pocketmine\player\Player;
use function get_class;
@@ -235,7 +234,9 @@ class ItemEntity extends Entity{
return;
}
$this->server->broadcastPackets($this->getViewers(), [TakeItemActorPacket::create($player->getId(), $this->getId())]);
foreach($this->getViewers() as $viewer){
$viewer->getNetworkSession()->onPlayerPickUpItem($player, $this);
}
$playerInventory->addItem(clone $item);
$this->flagForDespawn();

View File

@@ -31,7 +31,6 @@ use pocketmine\item\VanillaItems;
use pocketmine\math\RayTraceResult;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\ActorEventPacket;
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds;
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
use pocketmine\player\Player;
@@ -185,7 +184,9 @@ class Arrow extends Projectile{
return;
}
$this->server->broadcastPackets($this->getViewers(), [TakeItemActorPacket::create($player->getId(), $this->getId())]);
foreach($this->getViewers() as $viewer){
$viewer->getNetworkSession()->onPlayerPickUpItem($player, $this);
}
$playerInventory->addItem(clone $item);
$this->flagForDespawn();