PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
UpdateAttributesPacket.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
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
;
18
use
pocketmine\network\mcpe\protocol\types\entity\UpdateAttribute
;
19
use
function
count;
20
21
class
UpdateAttributesPacket
extends
DataPacket
implements
ClientboundPacket
{
22
public
const
NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET;
23
24
public
int
$actorRuntimeId;
26
public
array $entries = [];
27
public
int
$tick = 0;
28
33
public
static
function
create
(
int
$actorRuntimeId, array $entries,
int
$tick) : self{
34
$result = new self;
35
$result->actorRuntimeId = $actorRuntimeId;
36
$result->entries = $entries;
37
$result->tick = $tick;
38
return
$result;
39
}
40
41
protected
function
decodePayload
(
PacketSerializer
$in) : void{
42
$this->actorRuntimeId = $in->getActorRuntimeId();
43
for
($i = 0, $len = $in->
getUnsignedVarInt
(); $i < $len; ++$i){
44
$this->entries[] = UpdateAttribute::read($in);
45
}
46
$this->tick = $in->
getUnsignedVarLong
();
47
}
48
49
protected
function
encodePayload
(
PacketSerializer
$out) : void{
50
$out->putActorRuntimeId($this->actorRuntimeId);
51
$out->
putUnsignedVarInt
(count($this->entries));
52
foreach
($this->entries as $entry){
53
$entry->write($out);
54
}
55
$out->
putUnsignedVarLong
($this->tick);
56
}
57
58
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
59
return $handler->handleUpdateAttributes($this);
60
}
61
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\UpdateAttributesPacket
Definition
UpdateAttributesPacket.php:21
pocketmine\network\mcpe\protocol\UpdateAttributesPacket\handle
handle(PacketHandlerInterface $handler)
Definition
UpdateAttributesPacket.php:58
pocketmine\network\mcpe\protocol\UpdateAttributesPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
UpdateAttributesPacket.php:41
pocketmine\network\mcpe\protocol\UpdateAttributesPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
UpdateAttributesPacket.php:49
pocketmine\network\mcpe\protocol\UpdateAttributesPacket\create
static create(int $actorRuntimeId, array $entries, int $tick)
Definition
UpdateAttributesPacket.php:33
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\types\entity\UpdateAttribute
Definition
UpdateAttribute.php:20
pocketmine\utils\BinaryStream\putUnsignedVarLong
putUnsignedVarLong(int $v)
Definition
BinaryStream.php:348
pocketmine\utils\BinaryStream\getUnsignedVarInt
getUnsignedVarInt()
Definition
BinaryStream.php:307
pocketmine\utils\BinaryStream\getUnsignedVarLong
getUnsignedVarLong()
Definition
BinaryStream.php:341
pocketmine\utils\BinaryStream\putUnsignedVarInt
putUnsignedVarInt(int $v)
Definition
BinaryStream.php:314
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
UpdateAttributesPacket.php
Generated by
1.12.0