PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
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
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
19
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}
static create(BlockPosition $blockPosition, int $damageAmount)