PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
UpdateSubChunkBlocksPacketEntry.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;
16
19
21 public function __construct(
22 private BlockPosition $blockPosition,
23 private int $blockRuntimeId,
24 private int $flags,
25 //These two fields are useless 99.9% of the time; they are here to allow this packet to provide UpdateBlockSyncedPacket functionality.
26 private int $syncedUpdateActorUniqueId,
27 private int $syncedUpdateType
28 ){}
29
30 public static function simple(BlockPosition $blockPosition, int $blockRuntimeId) : self{
31 return new self($blockPosition, $blockRuntimeId, UpdateBlockPacket::FLAG_NETWORK, 0, 0);
32 }
33
34 public function getBlockPosition() : BlockPosition{ return $this->blockPosition; }
35
36 public function getBlockRuntimeId() : int{ return $this->blockRuntimeId; }
37
38 public function getFlags() : int{ return $this->flags; }
39
40 public function getSyncedUpdateActorUniqueId() : int{ return $this->syncedUpdateActorUniqueId; }
41
42 public function getSyncedUpdateType() : int{ return $this->syncedUpdateType; }
43
44 public static function read(PacketSerializer $in) : self{
45 $blockPosition = $in->getBlockPosition();
46 $blockRuntimeId = $in->getUnsignedVarInt();
47 $updateFlags = $in->getUnsignedVarInt();
48 $syncedUpdateActorUniqueId = $in->getUnsignedVarLong(); //this can't use the standard method because it's unsigned as opposed to the usual signed... !!!!!!
49 $syncedUpdateType = $in->getUnsignedVarInt(); //this isn't even consistent with UpdateBlockSyncedPacket?!
50
51 return new self($blockPosition, $blockRuntimeId, $updateFlags, $syncedUpdateActorUniqueId, $syncedUpdateType);
52 }
53
54 public function write(PacketSerializer $out) : void{
55 $out->putBlockPosition($this->blockPosition);
56 $out->putUnsignedVarInt($this->blockRuntimeId);
57 $out->putUnsignedVarInt($this->flags);
58 $out->putUnsignedVarLong($this->syncedUpdateActorUniqueId);
59 $out->putUnsignedVarInt($this->syncedUpdateType);
60 }
61}