PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
20
28 public const NETWORK_ID = ProtocolInfo::UPDATE_ADVENTURE_SETTINGS_PACKET;
29
30 private bool $noAttackingMobs;
31 private bool $noAttackingPlayers;
32 private bool $worldImmutable;
33 private bool $showNameTags;
34 private bool $autoJump;
35
39 public static function create(bool $noAttackingMobs, bool $noAttackingPlayers, bool $worldImmutable, bool $showNameTags, bool $autoJump) : self{
40 $result = new self;
41 $result->noAttackingMobs = $noAttackingMobs;
42 $result->noAttackingPlayers = $noAttackingPlayers;
43 $result->worldImmutable = $worldImmutable;
44 $result->showNameTags = $showNameTags;
45 $result->autoJump = $autoJump;
46 return $result;
47 }
48
49 public function isNoAttackingMobs() : bool{ return $this->noAttackingMobs; }
50
51 public function isNoAttackingPlayers() : bool{ return $this->noAttackingPlayers; }
52
53 public function isWorldImmutable() : bool{ return $this->worldImmutable; }
54
55 public function isShowNameTags() : bool{ return $this->showNameTags; }
56
57 public function isAutoJump() : bool{ return $this->autoJump; }
58
59 protected function decodePayload(ByteBufferReader $in) : void{
60 $this->noAttackingMobs = CommonTypes::getBool($in);
61 $this->noAttackingPlayers = CommonTypes::getBool($in);
62 $this->worldImmutable = CommonTypes::getBool($in);
63 $this->showNameTags = CommonTypes::getBool($in);
64 $this->autoJump = CommonTypes::getBool($in);
65 }
66
67 protected function encodePayload(ByteBufferWriter $out) : void{
68 CommonTypes::putBool($out, $this->noAttackingMobs);
69 CommonTypes::putBool($out, $this->noAttackingPlayers);
70 CommonTypes::putBool($out, $this->worldImmutable);
71 CommonTypes::putBool($out, $this->showNameTags);
72 CommonTypes::putBool($out, $this->autoJump);
73 }
74
75 public function handle(PacketHandlerInterface $handler) : bool{
76 return $handler->handleUpdateAdventureSettings($this);
77 }
78}
static create(bool $noAttackingMobs, bool $noAttackingPlayers, bool $worldImmutable, bool $showNameTags, bool $autoJump)