PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
SpawnParticleEffectPacket.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::SPAWN_PARTICLE_EFFECT_PACKET;
23
24 public int $dimensionId = DimensionIds::OVERWORLD; //wtf mojang
25 public int $actorUniqueId = -1; //default none
26 public Vector3 $position;
27 public string $particleName;
28 public ?string $molangVariablesJson = null;
29
33 public static function create(int $dimensionId, int $actorUniqueId, Vector3 $position, string $particleName, ?string $molangVariablesJson) : self{
34 $result = new self;
35 $result->dimensionId = $dimensionId;
36 $result->actorUniqueId = $actorUniqueId;
37 $result->position = $position;
38 $result->particleName = $particleName;
39 $result->molangVariablesJson = $molangVariablesJson;
40 return $result;
41 }
42
43 protected function decodePayload(PacketSerializer $in) : void{
44 $this->dimensionId = $in->getByte();
45 $this->actorUniqueId = $in->getActorUniqueId();
46 $this->position = $in->getVector3();
47 $this->particleName = $in->getString();
48 $this->molangVariablesJson = $in->getBool() ? $in->getString() : null;
49 }
50
51 protected function encodePayload(PacketSerializer $out) : void{
52 $out->putByte($this->dimensionId);
53 $out->putActorUniqueId($this->actorUniqueId);
54 $out->putVector3($this->position);
55 $out->putString($this->particleName);
56 $out->putBool($this->molangVariablesJson !== null);
57 if($this->molangVariablesJson !== null){
58 $out->putString($this->molangVariablesJson);
59 }
60 }
61
62 public function handle(PacketHandlerInterface $handler) : bool{
63 return $handler->handleSpawnParticleEffect($this);
64 }
65}
static create(int $dimensionId, int $actorUniqueId, Vector3 $position, string $particleName, ?string $molangVariablesJson)