PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
CompletedUsingItemPacket.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
18
20 public const NETWORK_ID = ProtocolInfo::COMPLETED_USING_ITEM_PACKET;
21
22 public const ACTION_UNKNOWN = -1;
23 public const ACTION_EQUIP_ARMOR = 0;
24 public const ACTION_EAT = 1;
25 public const ACTION_ATTACK = 2;
26 public const ACTION_CONSUME = 3;
27 public const ACTION_THROW = 4;
28 public const ACTION_SHOOT = 5;
29 public const ACTION_PLACE = 6;
30 public const ACTION_FILL_BOTTLE = 7;
31 public const ACTION_FILL_BUCKET = 8;
32 public const ACTION_POUR_BUCKET = 9;
33 public const ACTION_USE_TOOL = 10;
34 public const ACTION_INTERACT = 11;
35 public const ACTION_RETRIEVED = 12;
36 public const ACTION_DYED = 13;
37 public const ACTION_TRADED = 14;
38 public const ACTION_BRUSHING_COMPLETED = 15;
39
40 public int $itemId;
41 public int $action;
42
46 public static function create(int $itemId, int $action) : self{
47 $result = new self;
48 $result->itemId = $itemId;
49 $result->action = $action;
50 return $result;
51 }
52
53 public function decodePayload(PacketSerializer $in) : void{
54 $this->itemId = $in->getShort();
55 $this->action = $in->getLInt();
56 }
57
58 public function encodePayload(PacketSerializer $out) : void{
59 $out->putShort($this->itemId);
60 $out->putLInt($this->action);
61 }
62
63 public function handle(PacketHandlerInterface $handler) : bool{
64 return $handler->handleCompletedUsingItem($this);
65 }
66}