PocketMine-MP 5.16.1 git-585aee9386a787c95e73dd0a05ffca8329606b68
UpdateAdventureSettingsPacket.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;
16
18
26 public const NETWORK_ID = ProtocolInfo::UPDATE_ADVENTURE_SETTINGS_PACKET;
27
28 private bool $noAttackingMobs;
29 private bool $noAttackingPlayers;
30 private bool $worldImmutable;
31 private bool $showNameTags;
32 private bool $autoJump;
33
37 public static function create(bool $noAttackingMobs, bool $noAttackingPlayers, bool $worldImmutable, bool $showNameTags, bool $autoJump) : self{
38 $result = new self;
39 $result->noAttackingMobs = $noAttackingMobs;
40 $result->noAttackingPlayers = $noAttackingPlayers;
41 $result->worldImmutable = $worldImmutable;
42 $result->showNameTags = $showNameTags;
43 $result->autoJump = $autoJump;
44 return $result;
45 }
46
47 public function isNoAttackingMobs() : bool{ return $this->noAttackingMobs; }
48
49 public function isNoAttackingPlayers() : bool{ return $this->noAttackingPlayers; }
50
51 public function isWorldImmutable() : bool{ return $this->worldImmutable; }
52
53 public function isShowNameTags() : bool{ return $this->showNameTags; }
54
55 public function isAutoJump() : bool{ return $this->autoJump; }
56
57 protected function decodePayload(PacketSerializer $in) : void{
58 $this->noAttackingMobs = $in->getBool();
59 $this->noAttackingPlayers = $in->getBool();
60 $this->worldImmutable = $in->getBool();
61 $this->showNameTags = $in->getBool();
62 $this->autoJump = $in->getBool();
63 }
64
65 protected function encodePayload(PacketSerializer $out) : void{
66 $out->putBool($this->noAttackingMobs);
67 $out->putBool($this->noAttackingPlayers);
68 $out->putBool($this->worldImmutable);
69 $out->putBool($this->showNameTags);
70 $out->putBool($this->autoJump);
71 }
72
73 public function handle(PacketHandlerInterface $handler) : bool{
74 return $handler->handleUpdateAdventureSettings($this);
75 }
76}
static create(bool $noAttackingMobs, bool $noAttackingPlayers, bool $worldImmutable, bool $showNameTags, bool $autoJump)