This repository was archived by the owner on Jul 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathResourcePacksInfoPacket.php
More file actions
98 lines (83 loc) · 3.38 KB
/
Copy pathResourcePacksInfoPacket.php
File metadata and controls
98 lines (83 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry;
use Ramsey\Uuid\UuidInterface;
use function count;
class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET;
/** @var ResourcePackInfoEntry[] */
public array $resourcePackEntries = [];
public bool $mustAccept = false; //if true, forces client to choose between accepting packs or being disconnected
public bool $hasAddons = false;
public bool $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet
private UuidInterface $worldTemplateId;
private string $worldTemplateVersion;
private bool $forceDisableVibrantVisuals;
/**
* @generate-create-func
* @param ResourcePackInfoEntry[] $resourcePackEntries
*/
public static function create(
array $resourcePackEntries,
bool $mustAccept,
bool $hasAddons,
bool $hasScripts,
UuidInterface $worldTemplateId,
string $worldTemplateVersion,
bool $forceDisableVibrantVisuals,
) : self{
$result = new self;
$result->resourcePackEntries = $resourcePackEntries;
$result->mustAccept = $mustAccept;
$result->hasAddons = $hasAddons;
$result->hasScripts = $hasScripts;
$result->worldTemplateId = $worldTemplateId;
$result->worldTemplateVersion = $worldTemplateVersion;
$result->forceDisableVibrantVisuals = $forceDisableVibrantVisuals;
return $result;
}
public function getWorldTemplateId() : UuidInterface{ return $this->worldTemplateId; }
public function getWorldTemplateVersion() : string{ return $this->worldTemplateVersion; }
public function setForceDisablingVibrantVisuals(bool $forceDisable) : void{
$this->forceDisableVibrantVisuals = $forceDisable;
}
public function isForceDisablingVibrantVisuals() : bool{ return $this->forceDisableVibrantVisuals; }
protected function decodePayload(PacketSerializer $in) : void{
$this->mustAccept = $in->getBool();
$this->hasAddons = $in->getBool();
$this->hasScripts = $in->getBool();
$this->forceDisableVibrantVisuals = $in->getBool();
$this->worldTemplateId = $in->getUUID();
$this->worldTemplateVersion = $in->getString();
$resourcePackCount = $in->getLShort();
while($resourcePackCount-- > 0){
$this->resourcePackEntries[] = ResourcePackInfoEntry::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBool($this->mustAccept);
$out->putBool($this->hasAddons);
$out->putBool($this->hasScripts);
$out->putBool($this->forceDisableVibrantVisuals);
$out->putUUID($this->worldTemplateId);
$out->putString($this->worldTemplateVersion);
$out->putLShort(count($this->resourcePackEntries));
foreach($this->resourcePackEntries as $entry){
$entry->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleResourcePacksInfo($this);
}
}