PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
NpcRequestPacket.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
20 public const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET;
21
22 public const REQUEST_SET_ACTIONS = 0;
23 public const REQUEST_EXECUTE_ACTION = 1;
24 public const REQUEST_EXECUTE_CLOSING_COMMANDS = 2;
25 public const REQUEST_SET_NAME = 3;
26 public const REQUEST_SET_SKIN = 4;
27 public const REQUEST_SET_INTERACTION_TEXT = 5;
28 public const REQUEST_EXECUTE_OPENING_COMMANDS = 6;
29
30 public int $actorRuntimeId;
31 public int $requestType;
32 public string $commandString;
33 public int $actionIndex;
34 public string $sceneName;
35
39 public static function create(int $actorRuntimeId, int $requestType, string $commandString, int $actionIndex, string $sceneName) : self{
40 $result = new self;
41 $result->actorRuntimeId = $actorRuntimeId;
42 $result->requestType = $requestType;
43 $result->commandString = $commandString;
44 $result->actionIndex = $actionIndex;
45 $result->sceneName = $sceneName;
46 return $result;
47 }
48
49 protected function decodePayload(PacketSerializer $in) : void{
50 $this->actorRuntimeId = $in->getActorRuntimeId();
51 $this->requestType = $in->getByte();
52 $this->commandString = $in->getString();
53 $this->actionIndex = $in->getByte();
54 $this->sceneName = $in->getString();
55 }
56
57 protected function encodePayload(PacketSerializer $out) : void{
58 $out->putActorRuntimeId($this->actorRuntimeId);
59 $out->putByte($this->requestType);
60 $out->putString($this->commandString);
61 $out->putByte($this->actionIndex);
62 $out->putString($this->sceneName);
63 }
64
65 public function handle(PacketHandlerInterface $handler) : bool{
66 return $handler->handleNpcRequest($this);
67 }
68}
static create(int $actorRuntimeId, int $requestType, string $commandString, int $actionIndex, string $sceneName)