PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
LegacyTelemetryEventPacket.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\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\VarInt;
22
24 public const NETWORK_ID = ProtocolInfo::LEGACY_TELEMETRY_EVENT_PACKET;
25
26 public const TYPE_ACHIEVEMENT_AWARDED = 0;
27 public const TYPE_ENTITY_INTERACT = 1;
28 public const TYPE_PORTAL_BUILT = 2;
29 public const TYPE_PORTAL_USED = 3;
30 public const TYPE_MOB_KILLED = 4;
31 public const TYPE_CAULDRON_USED = 5;
32 public const TYPE_PLAYER_DEATH = 6;
33 public const TYPE_BOSS_KILLED = 7;
34 public const TYPE_AGENT_COMMAND = 8;
35 public const TYPE_AGENT_CREATED = 9;
36 public const TYPE_PATTERN_REMOVED = 10; //???
37 public const TYPE_COMMANED_EXECUTED = 11;
38 public const TYPE_FISH_BUCKETED = 12;
39 public const TYPE_MOB_BORN = 13;
40 public const TYPE_PET_DIED = 14;
41 public const TYPE_CAULDRON_BLOCK_USED = 15;
42 public const TYPE_COMPOSTER_BLOCK_USED = 16;
43 public const TYPE_BELL_BLOCK_USED = 17;
44 public const TYPE_ACTOR_DEFINITION = 18;
45 public const TYPE_RAID_UPDATE = 19;
46 public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat
47 public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21;
48 public const TYPE_HONEY_HARVESTED = 22;
49 public const TYPE_TARGET_BLOCK_HIT = 23;
50 public const TYPE_PIGLIN_BARTER = 24;
51
52 public int $playerRuntimeId;
53 public int $eventData;
54 public int $type;
55
56 protected function decodePayload(ByteBufferReader $in) : void{
57 $this->playerRuntimeId = CommonTypes::getActorRuntimeId($in);
58 $this->eventData = VarInt::readSignedInt($in);
59 $this->type = Byte::readUnsigned($in);
60
61 //TODO: nice confusing mess
62 }
63
64 protected function encodePayload(ByteBufferWriter $out) : void{
65 CommonTypes::putActorRuntimeId($out, $this->playerRuntimeId);
66 VarInt::writeSignedInt($out, $this->eventData);
67 Byte::writeUnsigned($out, $this->type);
68
69 //TODO: also nice confusing mess
70 }
71
72 public function handle(PacketHandlerInterface $handler) : bool{
73 return $handler->handleLegacyTelemetryEvent($this);
74 }
75}