PocketMine-MP 5.21.2 git-09bf203267aca9b83a09640e17bfac0fc7b58ff8
Loading...
Searching...
No Matches
AddItemActorPacket.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
21
23 public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET;
24
25 public int $actorUniqueId;
26 public int $actorRuntimeId;
27 public ItemStackWrapper $item;
28 public Vector3 $position;
29 public ?Vector3 $motion = null;
34 public array $metadata = [];
35 public bool $isFromFishing = false;
36
42 public static function create(
43 int $actorUniqueId,
44 int $actorRuntimeId,
45 ItemStackWrapper $item,
46 Vector3 $position,
47 ?Vector3 $motion,
48 array $metadata,
49 bool $isFromFishing,
50 ) : self{
51 $result = new self;
52 $result->actorUniqueId = $actorUniqueId;
53 $result->actorRuntimeId = $actorRuntimeId;
54 $result->item = $item;
55 $result->position = $position;
56 $result->motion = $motion;
57 $result->metadata = $metadata;
58 $result->isFromFishing = $isFromFishing;
59 return $result;
60 }
61
62 protected function decodePayload(PacketSerializer $in) : void{
63 $this->actorUniqueId = $in->getActorUniqueId();
64 $this->actorRuntimeId = $in->getActorRuntimeId();
65 $this->item = $in->getItemStackWrapper();
66 $this->position = $in->getVector3();
67 $this->motion = $in->getVector3();
68 $this->metadata = $in->getEntityMetadata();
69 $this->isFromFishing = $in->getBool();
70 }
71
72 protected function encodePayload(PacketSerializer $out) : void{
73 $out->putActorUniqueId($this->actorUniqueId);
74 $out->putActorRuntimeId($this->actorRuntimeId);
75 $out->putItemStackWrapper($this->item);
76 $out->putVector3($this->position);
77 $out->putVector3Nullable($this->motion);
78 $out->putEntityMetadata($this->metadata);
79 $out->putBool($this->isFromFishing);
80 }
81
82 public function handle(PacketHandlerInterface $handler) : bool{
83 return $handler->handleAddItemActor($this);
84 }
85}
static create(int $actorUniqueId, int $actorRuntimeId, ItemStackWrapper $item, Vector3 $position, ?Vector3 $motion, array $metadata, bool $isFromFishing,)