PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
AddVolumeEntityPacket.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
20
22 public const NETWORK_ID = ProtocolInfo::ADD_VOLUME_ENTITY_PACKET;
23
24 private int $entityNetId;
26 private CacheableNbt $data;
27 private string $jsonIdentifier;
28 private string $instanceName;
29 private BlockPosition $minBound;
30 private BlockPosition $maxBound;
31 private int $dimension;
32 private string $engineVersion;
33
38 public static function create(
39 int $entityNetId,
40 CacheableNbt $data,
41 string $jsonIdentifier,
42 string $instanceName,
43 BlockPosition $minBound,
44 BlockPosition $maxBound,
45 int $dimension,
46 string $engineVersion,
47 ) : self{
48 $result = new self;
49 $result->entityNetId = $entityNetId;
50 $result->data = $data;
51 $result->jsonIdentifier = $jsonIdentifier;
52 $result->instanceName = $instanceName;
53 $result->minBound = $minBound;
54 $result->maxBound = $maxBound;
55 $result->dimension = $dimension;
56 $result->engineVersion = $engineVersion;
57 return $result;
58 }
59
60 public function getEntityNetId() : int{ return $this->entityNetId; }
61
63 public function getData() : CacheableNbt{ return $this->data; }
64
65 public function getJsonIdentifier() : string{ return $this->jsonIdentifier; }
66
67 public function getInstanceName() : string{ return $this->instanceName; }
68
69 public function getMinBound() : BlockPosition{ return $this->minBound; }
70
71 public function getMaxBound() : BlockPosition{ return $this->maxBound; }
72
73 public function getDimension() : int{ return $this->dimension; }
74
75 public function getEngineVersion() : string{ return $this->engineVersion; }
76
77 protected function decodePayload(PacketSerializer $in) : void{
78 $this->entityNetId = $in->getUnsignedVarInt();
79 $this->data = new CacheableNbt($in->getNbtCompoundRoot());
80 $this->jsonIdentifier = $in->getString();
81 $this->instanceName = $in->getString();
82 $this->minBound = $in->getBlockPosition();
83 $this->maxBound = $in->getBlockPosition();
84 $this->dimension = $in->getVarInt();
85 $this->engineVersion = $in->getString();
86 }
87
88 protected function encodePayload(PacketSerializer $out) : void{
89 $out->putUnsignedVarInt($this->entityNetId);
90 $out->put($this->data->getEncodedNbt());
91 $out->putString($this->jsonIdentifier);
92 $out->putString($this->instanceName);
93 $out->putBlockPosition($this->minBound);
94 $out->putBlockPosition($this->maxBound);
95 $out->putVarInt($this->dimension);
96 $out->putString($this->engineVersion);
97 }
98
99 public function handle(PacketHandlerInterface $handler) : bool{
100 return $handler->handleAddVolumeEntity($this);
101 }
102}
static create(int $entityNetId, CacheableNbt $data, string $jsonIdentifier, string $instanceName, BlockPosition $minBound, BlockPosition $maxBound, int $dimension, string $engineVersion,)