PocketMine-MP 5.27.1 git-9af3cde03fabbe4129c79e46dc87ffa0fff446e6
Loading...
Searching...
No Matches
LevelSoundEventPacket.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
20
22 public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET;
23
25 public int $sound;
26 public Vector3 $position;
27 public int $extraData = -1;
28 public string $entityType = ":"; //???
29 public bool $isBabyMob = false; //...
30 public bool $disableRelativeVolume = false;
31 public int $actorUniqueId = -1;
32
36 public static function create(
37 int $sound,
38 Vector3 $position,
39 int $extraData,
40 string $entityType,
41 bool $isBabyMob,
42 bool $disableRelativeVolume,
43 int $actorUniqueId,
44 ) : self{
45 $result = new self;
46 $result->sound = $sound;
47 $result->position = $position;
48 $result->extraData = $extraData;
49 $result->entityType = $entityType;
50 $result->isBabyMob = $isBabyMob;
51 $result->disableRelativeVolume = $disableRelativeVolume;
52 $result->actorUniqueId = $actorUniqueId;
53 return $result;
54 }
55
56 public static function nonActorSound(int $sound, Vector3 $position, bool $disableRelativeVolume, int $extraData = -1) : self{
57 return self::create($sound, $position, $extraData, ":", false, $disableRelativeVolume, -1);
58 }
59
60 protected function decodePayload(PacketSerializer $in) : void{
61 $this->sound = $in->getUnsignedVarInt();
62 $this->position = $in->getVector3();
63 $this->extraData = $in->getVarInt();
64 $this->entityType = $in->getString();
65 $this->isBabyMob = $in->getBool();
66 $this->disableRelativeVolume = $in->getBool();
67 $this->actorUniqueId = $in->getLLong(); //WHY IS THIS NON-STANDARD?
68 }
69
70 protected function encodePayload(PacketSerializer $out) : void{
71 $out->putUnsignedVarInt($this->sound);
72 $out->putVector3($this->position);
73 $out->putVarInt($this->extraData);
74 $out->putString($this->entityType);
75 $out->putBool($this->isBabyMob);
76 $out->putBool($this->disableRelativeVolume);
77 $out->putLLong($this->actorUniqueId);
78 }
79
80 public function handle(PacketHandlerInterface $handler) : bool{
81 return $handler->handleLevelSoundEvent($this);
82 }
83}
static create(int $sound, Vector3 $position, int $extraData, string $entityType, bool $isBabyMob, bool $disableRelativeVolume, int $actorUniqueId,)