PocketMine-MP 5.41.1 git-fcc6fb5566a921cb669160c90f56fb68f5b29123
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
31 public function __construct(
32 private array $blocks,
33 private array $entities,
34 private array $blockTags,
35 private array $entityTypeFamilies
36 ){}
37
41 public function getBlocks() : array{ return $this->blocks; }
42
46 public function getEntities() : array{ return $this->entities; }
47
51 public function getBlockTags() : array{ return $this->blockTags; }
52
56 public function getEntityTypeFamilies() : array{ return $this->entityTypeFamilies; }
57
58 public static function read(ByteBufferReader $in) : self{
59 $blocks = [];
60 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
61 $blocks[] = CommonTypes::getString($in);
62 }
63
64 $entities = [];
65 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
66 $entities[] = CommonTypes::getString($in);
67 }
68
69 $blockTags = [];
70 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
71 $blockTags[] = CommonTypes::getString($in);
72 }
73
74 $entityTypeFamilies = [];
75 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
76 $entityTypeFamilies[] = CommonTypes::getString($in);
77 }
78
79 return new self(
80 $blocks,
81 $entities,
82 $blockTags,
83 $entityTypeFamilies
84 );
85 }
86
87 public function write(ByteBufferWriter $out) : void{
88 VarInt::writeUnsignedInt($out, count($this->blocks));
89 foreach($this->blocks as $block){
90 CommonTypes::putString($out, $block);
91 }
92
93 VarInt::writeUnsignedInt($out, count($this->entities));
94 foreach($this->entities as $entity){
95 CommonTypes::putString($out, $entity);
96 }
97
98 VarInt::writeUnsignedInt($out, count($this->blockTags));
99 foreach($this->blockTags as $blockTag){
100 CommonTypes::putString($out, $blockTag);
101 }
102
103 VarInt::writeUnsignedInt($out, count($this->entityTypeFamilies));
104 foreach($this->entityTypeFamilies as $entityTypeFamily){
105 CommonTypes::putString($out, $entityTypeFamily);
106 }
107 }
108}
__construct(private array $blocks, private array $entities, private array $blockTags, private array $entityTypeFamilies)