PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
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
18use function count;
19
21
26 public function __construct(
27 private array $entities,
28 private array $blocks,
29 private ?int $defaultEntityPriority,
30 private ?int $defaultBlockPriority
31 ){}
32
36 public function getEntities() : array{ return $this->entities; }
37
41 public function getBlocks() : array{ return $this->blocks; }
42
43 public function getDefaultEntityPriority() : ?int{ return $this->defaultEntityPriority; }
44
45 public function getDefaultBlockPriority() : ?int{ return $this->defaultBlockPriority; }
46
47 public static function read(PacketSerializer $in) : self{
48 $entities = [];
49 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
50 $entities[] = CameraAimAssistCategoryEntityPriority::read($in);
51 }
52
53 $blocks = [];
54 for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
55 $blocks[] = CameraAimAssistCategoryBlockPriority::read($in);
56 }
57
58 $defaultEntityPriority = $in->readOptional(fn() => $in->getLInt());
59 $defaultBlockPriority = $in->readOptional(fn() => $in->getLInt());
60 return new self(
61 $entities,
62 $blocks,
63 $defaultEntityPriority,
64 $defaultBlockPriority
65 );
66 }
67
68 public function write(PacketSerializer $out) : void{
69 $out->putUnsignedVarInt(count($this->entities));
70 foreach($this->entities as $entity){
71 $entity->write($out);
72 }
73
74 $out->putUnsignedVarInt(count($this->blocks));
75 foreach($this->blocks as $block){
76 $block->write($out);
77 }
78
79 $out->writeOptional($this->defaultEntityPriority, fn(int $v) => $out->putLInt($v));
80 $out->writeOptional($this->defaultBlockPriority, fn(int $v) => $out->putLInt($v));
81 }
82}
__construct(private array $entities, private array $blocks, private ?int $defaultEntityPriority, private ?int $defaultBlockPriority)