PocketMine-MP 5.39.3 git-66148f13a91e4af6778ba9f200ca25ad8a04a584
Loading...
Searching...
No Matches
CameraAimAssistCategoryPriorities.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\LE;
20use pmmp\encoding\VarInt;
22use function count;
23
25
31 public function __construct(
32 private array $entities,
33 private array $blocks,
34 private array $blockTags,
35 private ?int $defaultEntityPriority,
36 private ?int $defaultBlockPriority
37 ){}
38
42 public function getEntities() : array{ return $this->entities; }
43
47 public function getBlocks() : array{ return $this->blocks; }
48
52 public function getBlockTags() : array{ return $this->blockTags; }
53
54 public function getDefaultEntityPriority() : ?int{ return $this->defaultEntityPriority; }
55
56 public function getDefaultBlockPriority() : ?int{ return $this->defaultBlockPriority; }
57
58 public static function read(ByteBufferReader $in) : self{
59 $entities = [];
60 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
61 $entities[] = CameraAimAssistCategoryEntityPriority::read($in);
62 }
63
64 $blocks = [];
65 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
66 $blocks[] = CameraAimAssistCategoryBlockPriority::read($in);
67 }
68
69 $blockTags = [];
70 for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
71 $blockTags[] = VarInt::readUnsignedInt($in);
72 }
73
74 $defaultEntityPriority = CommonTypes::readOptional($in, LE::readSignedInt(...));
75 $defaultBlockPriority = CommonTypes::readOptional($in, LE::readSignedInt(...));
76 return new self(
77 $entities,
78 $blocks,
79 $blockTags,
80 $defaultEntityPriority,
81 $defaultBlockPriority
82 );
83 }
84
85 public function write(ByteBufferWriter $out) : void{
86 VarInt::writeUnsignedInt($out, count($this->entities));
87 foreach($this->entities as $entity){
88 $entity->write($out);
89 }
90
91 VarInt::writeUnsignedInt($out, count($this->blocks));
92 foreach($this->blocks as $block){
93 $block->write($out);
94 }
95
96 VarInt::writeUnsignedInt($out, count($this->blockTags));
97 foreach($this->blockTags as $tag){
98 VarInt::writeUnsignedInt($out, $tag);
99 }
100
101 CommonTypes::writeOptional($out, $this->defaultEntityPriority, LE::writeSignedInt(...));
102 CommonTypes::writeOptional($out, $this->defaultBlockPriority, LE::writeSignedInt(...));
103 }
104}
__construct(private array $entities, private array $blocks, private array $blockTags, private ?int $defaultEntityPriority, private ?int $defaultBlockPriority)