PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
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
13
declare(strict_types=1);
14
15
namespace
pocketmine\network\mcpe\protocol;
16
17
use pmmp\encoding\Byte;
18
use pmmp\encoding\ByteBufferReader;
19
use pmmp\encoding\ByteBufferWriter;
20
use
pocketmine\math\Vector3
;
21
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
22
use
pocketmine\network\mcpe\protocol\types\DimensionIds
;
23
24
class
SpawnParticleEffectPacket
extends
DataPacket
implements
ClientboundPacket
{
25
public
const
NETWORK_ID = ProtocolInfo::SPAWN_PARTICLE_EFFECT_PACKET;
26
27
public
int
$dimensionId = DimensionIds::OVERWORLD;
//wtf mojang
28
public
int
$actorUniqueId = -1;
//default none
29
public
Vector3
$position;
30
public
string
$particleName;
31
public
?
string
$molangVariablesJson =
null
;
32
36
public
static
function
create
(
int
$dimensionId,
int
$actorUniqueId,
Vector3
$position,
string
$particleName, ?
string
$molangVariablesJson) : self{
37
$result = new self;
38
$result->dimensionId = $dimensionId;
39
$result->actorUniqueId = $actorUniqueId;
40
$result->position = $position;
41
$result->particleName = $particleName;
42
$result->molangVariablesJson = $molangVariablesJson;
43
return
$result;
44
}
45
46
protected
function
decodePayload
(ByteBufferReader $in) : void{
47
$this->dimensionId = Byte::readUnsigned($in);
48
$this->actorUniqueId = CommonTypes::getActorUniqueId($in);
49
$this->position = CommonTypes::getVector3($in);
50
$this->particleName = CommonTypes::getString($in);
51
$this->molangVariablesJson = CommonTypes::getBool($in) ? CommonTypes::getString($in) : null;
52
}
53
54
protected
function
encodePayload
(ByteBufferWriter $out) : void{
55
Byte::writeUnsigned($out, $this->dimensionId);
56
CommonTypes::putActorUniqueId($out, $this->actorUniqueId);
57
CommonTypes::putVector3($out, $this->position);
58
CommonTypes::putString($out, $this->particleName);
59
CommonTypes::putBool($out, $this->molangVariablesJson !==
null
);
60
if
($this->molangVariablesJson !==
null
){
61
CommonTypes::putString($out, $this->molangVariablesJson);
62
}
63
}
64
65
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
66
return $handler->handleSpawnParticleEffect($this);
67
}
68
}
pocketmine\math\Vector3
Definition
Vector3.php:37
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket
Definition
SpawnParticleEffectPacket.php:24
pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
SpawnParticleEffectPacket.php:46
pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket\handle
handle(PacketHandlerInterface $handler)
Definition
SpawnParticleEffectPacket.php:65
pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket\create
static create(int $dimensionId, int $actorUniqueId, Vector3 $position, string $particleName, ?string $molangVariablesJson)
Definition
SpawnParticleEffectPacket.php:36
pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
SpawnParticleEffectPacket.php:54
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\types\DimensionIds
Definition
DimensionIds.php:17
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
SpawnParticleEffectPacket.php
Generated by
1.12.0