mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Moved EntityLink to its own type
This commit is contained in:
parent
78ca2f2e58
commit
eccc7bf7b3
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
|
||||
class AddEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||
@ -51,7 +52,7 @@ class AddEntityPacket extends DataPacket{
|
||||
public $attributes = [];
|
||||
/** @var array */
|
||||
public $metadata = [];
|
||||
/** @var array */
|
||||
/** @var EntityLink[] */
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload(){
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class AddPlayerPacket extends DataPacket{
|
||||
@ -65,6 +66,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
|
||||
public $long1 = 0;
|
||||
|
||||
/** @var EntityLink[] */
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload(){
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
@ -514,20 +515,26 @@ abstract class DataPacket extends BinaryStream{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return EntityLink
|
||||
*/
|
||||
protected function getEntityLink() : array{
|
||||
return [$this->getEntityUniqueId(), $this->getEntityUniqueId(), $this->getByte(), $this->getByte()];
|
||||
protected function getEntityLink() : EntityLink{
|
||||
$link = new EntityLink();
|
||||
$link->fromEntityUniqueId = $this->getEntityUniqueId();
|
||||
$link->toEntityUniqueId = $this->getEntityUniqueId();
|
||||
$link->type = $this->getByte();
|
||||
$link->byte2 = $this->getByte();
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $link
|
||||
* @param EntityLink $link
|
||||
*/
|
||||
protected function putEntityLink(array $link){
|
||||
$this->putEntityUniqueId($link[0]);
|
||||
$this->putEntityUniqueId($link[1]);
|
||||
$this->putByte($link[2]);
|
||||
$this->putByte($link[3]);
|
||||
protected function putEntityLink(EntityLink $link){
|
||||
$this->putEntityUniqueId($link->fromEntityUniqueId);
|
||||
$this->putEntityUniqueId($link->toEntityUniqueId);
|
||||
$this->putByte($link->type);
|
||||
$this->putByte($link->byte2);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,13 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
|
||||
class SetEntityLinkPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_ENTITY_LINK_PACKET;
|
||||
|
||||
/** @var array [from, to, type, unknown byte] */
|
||||
public $link = [];
|
||||
/** @var EntityLink */
|
||||
public $link;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->link = $this->getEntityLink();
|
||||
|
37
src/pocketmine/network/mcpe/protocol/types/EntityLink.php
Normal file
37
src/pocketmine/network/mcpe/protocol/types/EntityLink.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
class EntityLink{
|
||||
|
||||
/** @var int */
|
||||
public $fromEntityUniqueId;
|
||||
/** @var int */
|
||||
public $toEntityUniqueId;
|
||||
/** @var int */
|
||||
public $type;
|
||||
/** @var int */
|
||||
public $byte2;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user