PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
HurtArmorPacket.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\ByteBufferReader;
18
use pmmp\encoding\ByteBufferWriter;
19
use pmmp\encoding\VarInt;
20
21
class
HurtArmorPacket
extends
DataPacket
implements
ClientboundPacket
{
22
public
const
NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
23
24
public
int
$cause;
25
public
int
$health;
26
public
int
$armorSlotFlags;
27
31
public
static
function
create
(
int
$cause,
int
$health,
int
$armorSlotFlags) : self{
32
$result = new self;
33
$result->cause = $cause;
34
$result->health = $health;
35
$result->armorSlotFlags = $armorSlotFlags;
36
return
$result;
37
}
38
39
protected
function
decodePayload
(ByteBufferReader $in) : void{
40
$this->cause = VarInt::readSignedInt($in);
41
$this->health = VarInt::readSignedInt($in);
42
$this->armorSlotFlags = VarInt::readUnsignedLong($in);
43
}
44
45
protected
function
encodePayload
(ByteBufferWriter $out) : void{
46
VarInt::writeSignedInt($out, $this->cause);
47
VarInt::writeSignedInt($out, $this->health);
48
VarInt::writeUnsignedLong($out, $this->armorSlotFlags);
49
}
50
51
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
52
return $handler->handleHurtArmor($this);
53
}
54
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\HurtArmorPacket
Definition
HurtArmorPacket.php:21
pocketmine\network\mcpe\protocol\HurtArmorPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
HurtArmorPacket.php:39
pocketmine\network\mcpe\protocol\HurtArmorPacket\create
static create(int $cause, int $health, int $armorSlotFlags)
Definition
HurtArmorPacket.php:31
pocketmine\network\mcpe\protocol\HurtArmorPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
HurtArmorPacket.php:45
pocketmine\network\mcpe\protocol\HurtArmorPacket\handle
handle(PacketHandlerInterface $handler)
Definition
HurtArmorPacket.php:51
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
HurtArmorPacket.php
Generated by
1.12.0