PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
ItemStackResponseSlotInfo.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\types\inventory\stackresponse;
16
18
20 public function __construct(
21 private int $slot,
22 private int $hotbarSlot,
23 private int $count,
24 private int $itemStackId,
25 private string $customName,
26 private string $filteredCustomName,
27 private int $durabilityCorrection
28 ){}
29
30 public function getSlot() : int{ return $this->slot; }
31
32 public function getHotbarSlot() : int{ return $this->hotbarSlot; }
33
34 public function getCount() : int{ return $this->count; }
35
36 public function getItemStackId() : int{ return $this->itemStackId; }
37
38 public function getCustomName() : string{ return $this->customName; }
39
40 public function getFilteredCustomName() : string{ return $this->filteredCustomName; }
41
42 public function getDurabilityCorrection() : int{ return $this->durabilityCorrection; }
43
44 public static function read(PacketSerializer $in) : self{
45 $slot = $in->getByte();
46 $hotbarSlot = $in->getByte();
47 $count = $in->getByte();
48 $itemStackId = $in->readServerItemStackId();
49 $customName = $in->getString();
50 $filteredCustomName = $in->getString();
51 $durabilityCorrection = $in->getVarInt();
52 return new self($slot, $hotbarSlot, $count, $itemStackId, $customName, $filteredCustomName, $durabilityCorrection);
53 }
54
55 public function write(PacketSerializer $out) : void{
56 $out->putByte($this->slot);
57 $out->putByte($this->hotbarSlot);
58 $out->putByte($this->count);
59 $out->writeServerItemStackId($this->itemStackId);
60 $out->putString($this->customName);
61 $out->putString($this->filteredCustomName);
62 $out->putVarInt($this->durabilityCorrection);
63 }
64}