PocketMine-MP 5.39.2 git-7ad037014ecec1ddc7a9bba215beb03e659ea931
Loading...
Searching...
No Matches
CameraAimAssistPresetExclusionDefinition.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\camera;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\VarInt;
21use function count;
22
24
30 public function __construct(
31 private array $blocks,
32 private array $entities,
33 private array $blockTags,
34 ){}
35
39 public function getBlocks() : array{ return $this->blocks; }
40
44 public function getEntities() : array{ return $this->entities; }
45
49 public function getBlockTags() : array{ return $this->blockTags; }
50
51 public static function read(ByteBufferReader $in) : self{
52 $blocks = [];
53 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
54 $blocks[] = CommonTypes::getString($in);
55 }
56
57 $entities = [];
58 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
59 $entities[] = CommonTypes::getString($in);
60 }
61
62 $blockTags = [];
63 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
64 $blockTags[] = CommonTypes::getString($in);
65 }
66
67 return new self(
68 $blocks,
69 $entities,
70 $blockTags
71 );
72 }
73
74 public function write(ByteBufferWriter $out) : void{
75 VarInt::writeUnsignedInt($out, count($this->blocks));
76 foreach($this->blocks as $block){
77 CommonTypes::putString($out, $block);
78 }
79
80 VarInt::writeUnsignedInt($out, count($this->entities));
81 foreach($this->entities as $entity){
82 CommonTypes::putString($out, $entity);
83 }
84
85 VarInt::writeUnsignedInt($out, count($this->blockTags));
86 foreach($this->blockTags as $blockTag){
87 CommonTypes::putString($out, $blockTag);
88 }
89 }
90}
__construct(private array $blocks, private array $entities, private array $blockTags,)