PocketMine-MP 5.23.3 git-fbaa125d0ce21ffef98fc1630881a92bedfbaa73
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
35 public static function create(int $sound, Vector3 $position, int $extraData, string $entityType, bool $isBabyMob, bool $disableRelativeVolume) : self{
36 $result = new self;
37 $result->sound = $sound;
38 $result->position = $position;
39 $result->extraData = $extraData;
40 $result->entityType = $entityType;
41 $result->isBabyMob = $isBabyMob;
42 $result->disableRelativeVolume = $disableRelativeVolume;
43 return $result;
44 }
45
46 public static function nonActorSound(int $sound, Vector3 $position, bool $disableRelativeVolume, int $extraData = -1) : self{
47 return self::create($sound, $position, $extraData, ":", false, $disableRelativeVolume);
48 }
49
50 protected function decodePayload(PacketSerializer $in) : void{
51 $this->sound = $in->getUnsignedVarInt();
52 $this->position = $in->getVector3();
53 $this->extraData = $in->getVarInt();
54 $this->entityType = $in->getString();
55 $this->isBabyMob = $in->getBool();
56 $this->disableRelativeVolume = $in->getBool();
57 }
58
59 protected function encodePayload(PacketSerializer $out) : void{
60 $out->putUnsignedVarInt($this->sound);
61 $out->putVector3($this->position);
62 $out->putVarInt($this->extraData);
63 $out->putString($this->entityType);
64 $out->putBool($this->isBabyMob);
65 $out->putBool($this->disableRelativeVolume);
66 }
67
68 public function handle(PacketHandlerInterface $handler) : bool{
69 return $handler->handleLevelSoundEvent($this);
70 }
71}
static create(int $sound, Vector3 $position, int $extraData, string $entityType, bool $isBabyMob, bool $disableRelativeVolume)