PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
PlayerToggleCrafterSlotRequestPacket.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::PLAYER_TOGGLE_CRAFTER_SLOT_REQUEST_PACKET;
22
23 private BlockPosition $position;
24 private int $slot;
25 private bool $disabled;
26
30 public static function create(BlockPosition $position, int $slot, bool $disabled) : self{
31 $result = new self;
32 $result->position = $position;
33 $result->slot = $slot;
34 $result->disabled = $disabled;
35 return $result;
36 }
37
38 public function getPosition() : BlockPosition{ return $this->position; }
39
40 public function getSlot() : int{ return $this->slot; }
41
42 public function isDisabled() : bool{ return $this->disabled; }
43
44 protected function decodePayload(PacketSerializer $in) : void{
45 $x = $in->getLInt();
46 $y = $in->getLInt();
47 $z = $in->getLInt();
48 $this->position = new BlockPosition($x, $y, $z);
49 $this->slot = $in->getByte();
50 $this->disabled = $in->getBool();
51 }
52
53 protected function encodePayload(PacketSerializer $out) : void{
54 $out->putLInt($this->position->getX());
55 $out->putLInt($this->position->getY());
56 $out->putLInt($this->position->getZ());
57 $out->putByte($this->slot);
58 $out->putBool($this->disabled);
59 }
60
61 public function handle(PacketHandlerInterface $handler) : bool{
62 return $handler->handlePlayerToggleCrafterSlotRequest($this);
63 }
64}