PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
AnvilDamagePacket.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\BlockPosition
;
19
20
class
AnvilDamagePacket
extends
DataPacket
implements
ServerboundPacket
{
21
public
const
NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET;
22
23
private
BlockPosition
$blockPosition;
24
private
int
$damageAmount;
25
29
public
static
function
create
(
BlockPosition
$blockPosition,
int
$damageAmount) : self{
30
$result = new self;
31
$result->blockPosition = $blockPosition;
32
$result->damageAmount = $damageAmount;
33
return
$result;
34
}
35
36
public
function
getDamageAmount() : int{
37
return $this->damageAmount;
38
}
39
40
public
function
getBlockPosition() :
BlockPosition
{ return $this->blockPosition; }
41
42
protected
function
decodePayload
(
PacketSerializer
$in) : void{
43
$this->damageAmount = $in->getByte();
44
$this->blockPosition = $in->
getBlockPosition
();
45
}
46
47
protected
function
encodePayload
(
PacketSerializer
$out) : void{
48
$out->putByte($this->damageAmount);
49
$out->
putBlockPosition
($this->blockPosition);
50
}
51
52
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
53
return $handler->handleAnvilDamage($this);
54
}
55
}
pocketmine\network\mcpe\protocol\AnvilDamagePacket
Definition
AnvilDamagePacket.php:20
pocketmine\network\mcpe\protocol\AnvilDamagePacket\create
static create(BlockPosition $blockPosition, int $damageAmount)
Definition
AnvilDamagePacket.php:29
pocketmine\network\mcpe\protocol\AnvilDamagePacket\handle
handle(PacketHandlerInterface $handler)
Definition
AnvilDamagePacket.php:52
pocketmine\network\mcpe\protocol\AnvilDamagePacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
AnvilDamagePacket.php:47
pocketmine\network\mcpe\protocol\AnvilDamagePacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
AnvilDamagePacket.php:42
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\network\mcpe\protocol\serializer\PacketSerializer\getBlockPosition
getBlockPosition()
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:436
pocketmine\network\mcpe\protocol\serializer\PacketSerializer\putBlockPosition
putBlockPosition(BlockPosition $blockPosition)
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:446
pocketmine\network\mcpe\protocol\types\BlockPosition
Definition
BlockPosition.php:19
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
pocketmine\network\mcpe\protocol\ServerboundPacket
Definition
ServerboundPacket.php:17
vendor
pocketmine
bedrock-protocol
src
AnvilDamagePacket.php
Generated by
1.12.0