PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
ContainerSetDataPacket.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
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\VarInt;
21
23 public const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET;
24
25 public const PROPERTY_FURNACE_SMELT_PROGRESS = 0;
26 public const PROPERTY_FURNACE_REMAINING_FUEL_TIME = 1;
27 public const PROPERTY_FURNACE_MAX_FUEL_TIME = 2;
28 public const PROPERTY_FURNACE_STORED_XP = 3;
29 public const PROPERTY_FURNACE_FUEL_AUX = 4;
30
31 public const PROPERTY_BREWING_STAND_BREW_TIME = 0;
32 public const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1;
33 public const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2;
34
35 public int $windowId;
36 public int $property;
37 public int $value;
38
42 public static function create(int $windowId, int $property, int $value) : self{
43 $result = new self;
44 $result->windowId = $windowId;
45 $result->property = $property;
46 $result->value = $value;
47 return $result;
48 }
49
50 protected function decodePayload(ByteBufferReader $in) : void{
51 $this->windowId = Byte::readUnsigned($in);
52 $this->property = VarInt::readSignedInt($in);
53 $this->value = VarInt::readSignedInt($in);
54 }
55
56 protected function encodePayload(ByteBufferWriter $out) : void{
57 Byte::writeUnsigned($out, $this->windowId);
58 VarInt::writeSignedInt($out, $this->property);
59 VarInt::writeSignedInt($out, $this->value);
60 }
61
62 public function handle(PacketHandlerInterface $handler) : bool{
63 return $handler->handleContainerSetData($this);
64 }
65}
static create(int $windowId, int $property, int $value)