PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
LevelSoundEventPacketV2.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
19
24 public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V2;
25
26 public int $sound;
27 public Vector3 $position;
28 public int $extraData = -1;
29 public string $entityType = ":"; //???
30 public bool $isBabyMob = false; //...
31 public bool $disableRelativeVolume = false;
32
36 public static function create(int $sound, Vector3 $position, int $extraData, string $entityType, bool $isBabyMob, bool $disableRelativeVolume) : self{
37 $result = new self;
38 $result->sound = $sound;
39 $result->position = $position;
40 $result->extraData = $extraData;
41 $result->entityType = $entityType;
42 $result->isBabyMob = $isBabyMob;
43 $result->disableRelativeVolume = $disableRelativeVolume;
44 return $result;
45 }
46
47 protected function decodePayload(PacketSerializer $in) : void{
48 $this->sound = $in->getByte();
49 $this->position = $in->getVector3();
50 $this->extraData = $in->getVarInt();
51 $this->entityType = $in->getString();
52 $this->isBabyMob = $in->getBool();
53 $this->disableRelativeVolume = $in->getBool();
54 }
55
56 protected function encodePayload(PacketSerializer $out) : void{
57 $out->putByte($this->sound);
58 $out->putVector3($this->position);
59 $out->putVarInt($this->extraData);
60 $out->putString($this->entityType);
61 $out->putBool($this->isBabyMob);
62 $out->putBool($this->disableRelativeVolume);
63 }
64
65 public function handle(PacketHandlerInterface $handler) : bool{
66 return $handler->handleLevelSoundEventPacketV2($this);
67 }
68}
static create(int $sound, Vector3 $position, int $extraData, string $entityType, bool $isBabyMob, bool $disableRelativeVolume)