mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 04:15:04 +00:00
MCPE protocol gets its own namespace
This commit is contained in:
80
src/pocketmine/network/mcpe/protocol/AddEntityPacket.php
Normal file
80
src/pocketmine/network/mcpe/protocol/AddEntityPacket.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $type;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
public $yaw;
|
||||
public $pitch;
|
||||
/** @var Attribute[] */
|
||||
public $attributes = [];
|
||||
public $metadata = [];
|
||||
public $links = [];
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid); //EntityUniqueID - TODO: verify this
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putUnsignedVarInt($this->type);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->putLFloat($this->pitch * (256 / 360));
|
||||
$this->putLFloat($this->yaw * (256 / 360));
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $entry){
|
||||
$this->putString($entry->getName());
|
||||
$this->putLFloat($entry->getMinValue());
|
||||
$this->putLFloat($entry->getValue());
|
||||
$this->putLFloat($entry->getMaxValue());
|
||||
}
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putEntityId($link[0]);
|
||||
$this->putEntityId($link[1]);
|
||||
$this->putByte($link[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddEntity($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddHangingEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET;
|
||||
|
||||
public $entityUniqueId;
|
||||
public $entityRuntimeId;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->entityUniqueId);
|
||||
$this->putEntityId($this->entityRuntimeId);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddHangingEntity($this);
|
||||
}
|
||||
|
||||
}
|
58
src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php
Normal file
58
src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddItemEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $item;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putSlot($this->item);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddItemEntity($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/AddItemPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/AddItemPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddItemPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_ITEM_PACKET;
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddItem($this);
|
||||
}
|
||||
|
||||
}
|
56
src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php
Normal file
56
src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddPaintingPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $direction;
|
||||
public $title;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->direction);
|
||||
$this->putString($this->title);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddPainting($this);
|
||||
}
|
||||
|
||||
}
|
69
src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php
Normal file
69
src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddPlayerPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET;
|
||||
|
||||
public $uuid;
|
||||
public $username;
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
public $pitch;
|
||||
public $headYaw;
|
||||
public $yaw;
|
||||
public $item;
|
||||
public $metadata = [];
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putUUID($this->uuid);
|
||||
$this->putString($this->username);
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putSlot($this->item);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddPlayer($this);
|
||||
}
|
||||
|
||||
}
|
104
src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php
Normal file
104
src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AdventureSettingsPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
|
||||
|
||||
const PERMISSION_NORMAL = 0;
|
||||
const PERMISSION_OPERATOR = 1;
|
||||
const PERMISSION_HOST = 2;
|
||||
const PERMISSION_AUTOMATION = 3;
|
||||
const PERMISSION_ADMIN = 4;
|
||||
|
||||
public $worldImmutable = false;
|
||||
public $noPvp = false;
|
||||
public $noPvm = false;
|
||||
public $noMvp = false;
|
||||
|
||||
public $autoJump = true;
|
||||
public $allowFlight = false;
|
||||
public $noClip = false;
|
||||
public $worldBuilder = false;
|
||||
public $isFlying = false;
|
||||
|
||||
/*
|
||||
bit mask | flag name
|
||||
0x00000001 world_immutable
|
||||
0x00000002 no_pvp
|
||||
0x00000004 no_pvm
|
||||
0x00000008 no_mvp
|
||||
0x00000010 ?
|
||||
0x00000020 auto_jump
|
||||
0x00000040 allow_fly
|
||||
0x00000080 noclip
|
||||
0x00000100 world_builder (seems to allow building even if the world_immutable flag is set (???))
|
||||
0x00000200 is_flying
|
||||
*/
|
||||
|
||||
public $flags = 0;
|
||||
public $userPermission;
|
||||
|
||||
public function decode(){
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->userPermission = $this->getUnsignedVarInt();
|
||||
|
||||
$this->worldImmutable = (bool) ($this->flags & 1);
|
||||
$this->noPvp = (bool) ($this->flags & (1 << 1));
|
||||
$this->noPvm = (bool) ($this->flags & (1 << 2));
|
||||
$this->noMvp = (bool) ($this->flags & (1 << 3));
|
||||
|
||||
$this->autoJump = (bool) ($this->flags & (1 << 5));
|
||||
$this->allowFlight = (bool) ($this->flags & (1 << 6));
|
||||
$this->noClip = (bool) ($this->flags & (1 << 7));
|
||||
$this->worldBuilder = (bool) ($this->flags & (1 << 8));
|
||||
$this->isFlying = (bool) ($this->flags & (1 << 9));
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
|
||||
$this->flags |= ((int) $this->worldImmutable);
|
||||
$this->flags |= ((int) $this->noPvp) << 1;
|
||||
$this->flags |= ((int) $this->noPvm) << 2;
|
||||
$this->flags |= ((int) $this->noMvp) << 3;
|
||||
|
||||
$this->flags |= ((int) $this->autoJump) << 5;
|
||||
$this->flags |= ((int) $this->allowFlight) << 6;
|
||||
$this->flags |= ((int) $this->noClip) << 7;
|
||||
$this->flags |= ((int) $this->worldBuilder) << 8;
|
||||
$this->flags |= ((int) $this->isFlying) << 9;
|
||||
|
||||
$this->putUnsignedVarInt($this->flags);
|
||||
$this->putUnsignedVarInt($this->userPermission);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAdventureSettings($this);
|
||||
}
|
||||
|
||||
}
|
50
src/pocketmine/network/mcpe/protocol/AnimatePacket.php
Normal file
50
src/pocketmine/network/mcpe/protocol/AnimatePacket.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AnimatePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET;
|
||||
|
||||
public $action;
|
||||
public $eid;
|
||||
|
||||
public function decode(){
|
||||
$this->action = $this->getVarInt();
|
||||
$this->eid = $this->getEntityId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->action);
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAnimate($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AvailableCommandsPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::AVAILABLE_COMMANDS_PACKET;
|
||||
|
||||
public $commands; //JSON-encoded command data
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putString($this->commands);
|
||||
$this->putString($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAvailableCommands($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/BatchPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/BatchPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BatchPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::BATCH_PACKET;
|
||||
|
||||
public $payload;
|
||||
|
||||
public function decode(){
|
||||
$this->payload = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putString($this->payload);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBatch($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BlockEntityDataPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $namedtag;
|
||||
|
||||
public function decode(){
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->get(true);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->put($this->namedtag);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockEntityData($this);
|
||||
}
|
||||
|
||||
}
|
53
src/pocketmine/network/mcpe/protocol/BlockEventPacket.php
Normal file
53
src/pocketmine/network/mcpe/protocol/BlockEventPacket.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BlockEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $case1;
|
||||
public $case2;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->case1);
|
||||
$this->putVarInt($this->case2);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockEvent($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ChangeDimensionPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET;
|
||||
|
||||
const DIMENSION_OVERWORLD = 0;
|
||||
const DIMENSION_NETHER = 1;
|
||||
|
||||
public $dimension;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknown; //bool
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleChangeDimension($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ChunkRadiusUpdatedPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET;
|
||||
|
||||
public $radius;
|
||||
|
||||
public function decode(){
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleChunkRadiusUpdated($this);
|
||||
}
|
||||
|
||||
}
|
74
src/pocketmine/network/mcpe/protocol/CommandStepPacket.php
Normal file
74
src/pocketmine/network/mcpe/protocol/CommandStepPacket.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CommandStepPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::COMMAND_STEP_PACKET;
|
||||
|
||||
/**
|
||||
* unknown (string)
|
||||
* unknown (string)
|
||||
* unknown (uvarint)
|
||||
* unknown (uvarint)
|
||||
* unknown (bool)
|
||||
* unknown (uvarint64)
|
||||
* unknown (string)
|
||||
* unknown (string)
|
||||
* https://gist.github.com/dktapps/8285b93af4ca38e0104bfeb9a6c87afd
|
||||
*/
|
||||
|
||||
public $command;
|
||||
public $overload;
|
||||
public $uvarint1;
|
||||
public $uvarint2;
|
||||
public $bool;
|
||||
public $uvarint64;
|
||||
public $args; //JSON formatted command arguments
|
||||
public $string4;
|
||||
|
||||
public function decode(){
|
||||
$this->command = $this->getString();
|
||||
$this->overload = $this->getString();
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
$this->uvarint2 = $this->getUnsignedVarInt();
|
||||
$this->bool = (bool) $this->getByte();
|
||||
$this->uvarint64 = $this->getUnsignedVarInt(); //TODO: varint64
|
||||
$this->args = json_decode($this->getString());
|
||||
$this->string4 = $this->getString();
|
||||
while(!$this->feof()){
|
||||
$this->getByte(); //prevent assertion errors. TODO: find out why there are always 3 extra bytes at the end of this packet.
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCommandStep($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ContainerClosePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;
|
||||
|
||||
public $windowid;
|
||||
|
||||
public function decode(){
|
||||
$this->windowid = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerClose($this);
|
||||
}
|
||||
}
|
57
src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php
Normal file
57
src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ContainerOpenPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET;
|
||||
|
||||
public $windowid;
|
||||
public $type;
|
||||
public $slots;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $entityId = -1;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putByte($this->type);
|
||||
$this->putVarInt($this->slots);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putEntityId($this->entityId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerOpen($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ContainerSetContentPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
|
||||
|
||||
const SPECIAL_INVENTORY = 0;
|
||||
const SPECIAL_ARMOR = 0x78;
|
||||
const SPECIAL_CREATIVE = 0x79;
|
||||
const SPECIAL_HOTBAR = 0x7a;
|
||||
|
||||
public $windowid;
|
||||
public $slots = [];
|
||||
public $hotbar = [];
|
||||
|
||||
public function clean(){
|
||||
$this->slots = [];
|
||||
$this->hotbar = [];
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
$this->windowid = $this->getByte();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
for($s = 0; $s < $count and !$this->feof(); ++$s){
|
||||
$this->slots[$s] = $this->getSlot();
|
||||
}
|
||||
if($this->windowid === self::SPECIAL_INVENTORY){
|
||||
$count = $this->getUnsignedVarInt();
|
||||
for($s = 0; $s < $count and !$this->feof(); ++$s){
|
||||
$this->hotbar[$s] = $this->getVarInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putUnsignedVarInt(count($this->slots));
|
||||
foreach($this->slots as $slot){
|
||||
$this->putSlot($slot);
|
||||
}
|
||||
if($this->windowid === self::SPECIAL_INVENTORY and count($this->hotbar) > 0){
|
||||
$this->putUnsignedVarInt(count($this->hotbar));
|
||||
foreach($this->hotbar as $slot){
|
||||
$this->putVarInt($slot);
|
||||
}
|
||||
}else{
|
||||
$this->putUnsignedVarInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerSetContent($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ContainerSetDataPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET;
|
||||
|
||||
public $windowid;
|
||||
public $property;
|
||||
public $value;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putVarInt($this->property);
|
||||
$this->putVarInt($this->value);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerSetData($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ContainerSetSlotPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_SLOT_PACKET;
|
||||
|
||||
public $windowid;
|
||||
public $slot;
|
||||
public $hotbarSlot;
|
||||
/** @var Item */
|
||||
public $item;
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
$this->windowid = $this->getByte();
|
||||
$this->slot = $this->getVarInt();
|
||||
$this->hotbarSlot = $this->getVarInt();
|
||||
$this->item = $this->getSlot();
|
||||
$this->unknown = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putVarInt($this->slot);
|
||||
$this->putVarInt($this->hotbarSlot);
|
||||
$this->putSlot($this->item);
|
||||
$this->putByte($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerSetSlot($this);
|
||||
}
|
||||
|
||||
}
|
205
src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php
Normal file
205
src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
|
||||
class CraftingDataPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CRAFTING_DATA_PACKET;
|
||||
|
||||
const ENTRY_SHAPELESS = 0;
|
||||
const ENTRY_SHAPED = 1;
|
||||
const ENTRY_FURNACE = 2;
|
||||
const ENTRY_FURNACE_DATA = 3;
|
||||
const ENTRY_MULTI = 4;
|
||||
|
||||
/** @var object[] */
|
||||
public $entries = [];
|
||||
public $cleanRecipes = false;
|
||||
|
||||
public function clean(){
|
||||
$this->entries = [];
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
$entries = [];
|
||||
$recipeCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $recipeCount; ++$i){
|
||||
$entry = [];
|
||||
$entry["type"] = $recipeType = $this->getVarInt();
|
||||
|
||||
switch($recipeType){
|
||||
case self::ENTRY_SHAPELESS:
|
||||
$ingredientCount = $this->getUnsignedVarInt();
|
||||
/** @var Item */
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $ingredientCount; ++$j){
|
||||
$entry["input"][] = $this->getSlot();
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_SHAPED:
|
||||
$entry["width"] = $this->getVarInt();
|
||||
$entry["height"] = $this->getVarInt();
|
||||
$count = $entry["width"] * $entry["height"];
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $count; ++$j){
|
||||
$entry["input"][] = $this->getSlot();
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
break;
|
||||
case self::ENTRY_FURNACE:
|
||||
case self::ENTRY_FURNACE_DATA:
|
||||
$entry["inputId"] = $this->getVarInt();
|
||||
if($recipeType === self::ENTRY_FURNACE_DATA){
|
||||
$entry["inputDamage"] = $this->getVarInt();
|
||||
}
|
||||
$entry["output"] = $this->getSlot();
|
||||
break;
|
||||
case self::ENTRY_MULTI:
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
break;
|
||||
default:
|
||||
throw new \UnexpectedValueException("Unhandled recipe type $recipeType!"); //do not continue attempting to decode
|
||||
}
|
||||
$entries[] = $entry;
|
||||
}
|
||||
$this->getBool(); //cleanRecipes
|
||||
}
|
||||
|
||||
private static function writeEntry($entry, BinaryStream $stream){
|
||||
if($entry instanceof ShapelessRecipe){
|
||||
return self::writeShapelessRecipe($entry, $stream);
|
||||
}elseif($entry instanceof ShapedRecipe){
|
||||
return self::writeShapedRecipe($entry, $stream);
|
||||
}elseif($entry instanceof FurnaceRecipe){
|
||||
return self::writeFurnaceRecipe($entry, $stream);
|
||||
}
|
||||
//TODO: add MultiRecipe
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static function writeShapelessRecipe(ShapelessRecipe $recipe, BinaryStream $stream){
|
||||
$stream->putUnsignedVarInt($recipe->getIngredientCount());
|
||||
foreach($recipe->getIngredientList() as $item){
|
||||
$stream->putSlot($item);
|
||||
}
|
||||
|
||||
$stream->putUnsignedVarInt(1);
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
$stream->putUUID($recipe->getId());
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPELESS;
|
||||
}
|
||||
|
||||
private static function writeShapedRecipe(ShapedRecipe $recipe, BinaryStream $stream){
|
||||
$stream->putVarInt($recipe->getWidth());
|
||||
$stream->putVarInt($recipe->getHeight());
|
||||
|
||||
for($z = 0; $z < $recipe->getHeight(); ++$z){
|
||||
for($x = 0; $x < $recipe->getWidth(); ++$x){
|
||||
$stream->putSlot($recipe->getIngredient($x, $z));
|
||||
}
|
||||
}
|
||||
|
||||
$stream->putUnsignedVarInt(1);
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
$stream->putUUID($recipe->getId());
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPED;
|
||||
}
|
||||
|
||||
private static function writeFurnaceRecipe(FurnaceRecipe $recipe, BinaryStream $stream){
|
||||
if(!$recipe->getInput()->hasAnyDamageValue()){ //Data recipe
|
||||
$stream->putVarInt($recipe->getInput()->getId());
|
||||
$stream->putVarInt($recipe->getInput()->getDamage());
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
return CraftingDataPacket::ENTRY_FURNACE_DATA;
|
||||
}else{
|
||||
$stream->putVarInt($recipe->getInput()->getId());
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
return CraftingDataPacket::ENTRY_FURNACE;
|
||||
}
|
||||
}
|
||||
|
||||
public function addShapelessRecipe(ShapelessRecipe $recipe){
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
public function addShapedRecipe(ShapedRecipe $recipe){
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
public function addFurnaceRecipe(FurnaceRecipe $recipe){
|
||||
$this->entries[] = $recipe;
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
|
||||
$writer = new BinaryStream();
|
||||
foreach($this->entries as $d){
|
||||
$entryType = self::writeEntry($d, $writer);
|
||||
if($entryType >= 0){
|
||||
$this->putVarInt($entryType);
|
||||
$this->put($writer->getBuffer());
|
||||
}else{
|
||||
$this->putVarInt(-1);
|
||||
}
|
||||
|
||||
$writer->reset();
|
||||
}
|
||||
|
||||
$this->putBool($this->cleanRecipes);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCraftingData($this);
|
||||
}
|
||||
|
||||
}
|
70
src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php
Normal file
70
src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CraftingEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET;
|
||||
|
||||
public $windowId;
|
||||
public $type;
|
||||
public $id;
|
||||
/** @var Item[] */
|
||||
public $input = [];
|
||||
/** @var Item[] */
|
||||
public $output = [];
|
||||
|
||||
public function clean(){
|
||||
$this->input = [];
|
||||
$this->output = [];
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
$this->windowId = $this->getByte();
|
||||
$this->type = $this->getVarInt();
|
||||
$this->id = $this->getUUID();
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->input[] = $this->getSlot();
|
||||
}
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->output[] = $this->getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCraftingEvent($this);
|
||||
}
|
||||
|
||||
}
|
185
src/pocketmine/network/mcpe/protocol/DataPacket.php
Normal file
185
src/pocketmine/network/mcpe/protocol/DataPacket.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
|
||||
abstract class DataPacket extends BinaryStream{
|
||||
|
||||
const NETWORK_ID = 0;
|
||||
|
||||
public $isEncoded = false;
|
||||
|
||||
public function pid(){
|
||||
return $this::NETWORK_ID;
|
||||
}
|
||||
|
||||
abstract public function encode();
|
||||
|
||||
abstract public function decode();
|
||||
|
||||
abstract public function handle(NetworkSession $session) : bool;
|
||||
|
||||
public function reset(){
|
||||
$this->buffer = chr($this::NETWORK_ID);
|
||||
$this->offset = 0;
|
||||
}
|
||||
|
||||
public function clean(){
|
||||
$this->buffer = null;
|
||||
$this->isEncoded = false;
|
||||
$this->offset = 0;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __debugInfo(){
|
||||
$data = [];
|
||||
foreach($this as $k => $v){
|
||||
if($k === "buffer"){
|
||||
$data[$k] = bin2hex($v);
|
||||
}elseif(is_string($v) or (is_object($v) and method_exists($v, "__toString"))){
|
||||
$data[$k] = Utils::printable((string) $v);
|
||||
}else{
|
||||
$data[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes entity metadata from the stream.
|
||||
*
|
||||
* @param bool $types Whether to include metadata types along with values in the returned array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntityMetadata(bool $types = true) : array{
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$data = [];
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$key = $this->getUnsignedVarInt();
|
||||
$type = $this->getUnsignedVarInt();
|
||||
$value = null;
|
||||
switch($type){
|
||||
case Entity::DATA_TYPE_BYTE:
|
||||
$value = $this->getByte();
|
||||
break;
|
||||
case Entity::DATA_TYPE_SHORT:
|
||||
$value = $this->getLShort(true); //signed
|
||||
break;
|
||||
case Entity::DATA_TYPE_INT:
|
||||
$value = $this->getVarInt();
|
||||
break;
|
||||
case Entity::DATA_TYPE_FLOAT:
|
||||
$value = $this->getLFloat();
|
||||
break;
|
||||
case Entity::DATA_TYPE_STRING:
|
||||
$value = $this->getString();
|
||||
break;
|
||||
case Entity::DATA_TYPE_SLOT:
|
||||
//TODO: use objects directly
|
||||
$value = [];
|
||||
$item = $this->getSlot();
|
||||
$value[0] = $item->getId();
|
||||
$value[1] = $item->getCount();
|
||||
$value[2] = $item->getDamage();
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
$value = [];
|
||||
$value[0] = $this->getVarInt(); //x
|
||||
$value[1] = $this->getVarInt(); //y (SIGNED)
|
||||
$value[2] = $this->getVarInt(); //z
|
||||
break;
|
||||
case Entity::DATA_TYPE_LONG:
|
||||
$value = $this->getVarInt(); //TODO: varint64 proper support
|
||||
break;
|
||||
case Entity::DATA_TYPE_VECTOR3F:
|
||||
$value = [0.0, 0.0, 0.0];
|
||||
$this->getVector3f($value[0], $value[1], $value[2]);
|
||||
break;
|
||||
default:
|
||||
$value = [];
|
||||
}
|
||||
if($types === true){
|
||||
$data[$key] = [$value, $type];
|
||||
}else{
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes entity metadata to the packet buffer.
|
||||
*
|
||||
* @param array $metadata
|
||||
*/
|
||||
public function putEntityMetadata(array $metadata){
|
||||
$this->putUnsignedVarInt(count($metadata));
|
||||
foreach($metadata as $key => $d){
|
||||
$this->putUnsignedVarInt($key); //data key
|
||||
$this->putUnsignedVarInt($d[0]); //data type
|
||||
switch($d[0]){
|
||||
case Entity::DATA_TYPE_BYTE:
|
||||
$this->putByte($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_SHORT:
|
||||
$this->putLShort($d[1]); //SIGNED short!
|
||||
break;
|
||||
case Entity::DATA_TYPE_INT:
|
||||
$this->putVarInt($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_FLOAT:
|
||||
$this->putLFloat($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_STRING:
|
||||
$this->putString($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_SLOT:
|
||||
//TODO: change this implementation (use objects)
|
||||
$this->putSlot(Item::get($d[1][0], $d[1][2], $d[1][1])); //ID, damage, count
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
//TODO: change this implementation (use objects)
|
||||
$this->putVarInt($d[1][0]); //x
|
||||
$this->putVarInt($d[1][1]); //y (SIGNED)
|
||||
$this->putVarInt($d[1][2]); //z
|
||||
break;
|
||||
case Entity::DATA_TYPE_LONG:
|
||||
$this->putVarInt($d[1]); //TODO: varint64 support
|
||||
break;
|
||||
case Entity::DATA_TYPE_VECTOR3F:
|
||||
//TODO: change this implementation (use objects)
|
||||
$this->putVector3f($d[1][0], $d[1][1], $d[1][2]); //x, y, z
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
src/pocketmine/network/mcpe/protocol/DisconnectPacket.php
Normal file
50
src/pocketmine/network/mcpe/protocol/DisconnectPacket.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class DisconnectPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET;
|
||||
|
||||
public $hideDisconnectionScreen = false;
|
||||
public $message;
|
||||
|
||||
public function decode(){
|
||||
$this->hideDisconnectionScreen = $this->getBool();
|
||||
$this->message = $this->getString();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBool($this->hideDisconnectionScreen);
|
||||
$this->putString($this->message);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleDisconnect($this);
|
||||
}
|
||||
|
||||
}
|
48
src/pocketmine/network/mcpe/protocol/DropItemPacket.php
Normal file
48
src/pocketmine/network/mcpe/protocol/DropItemPacket.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class DropItemPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::DROP_ITEM_PACKET;
|
||||
|
||||
public $type;
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
$this->type = $this->getByte();
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleDropItem($this);
|
||||
}
|
||||
|
||||
}
|
71
src/pocketmine/network/mcpe/protocol/EntityEventPacket.php
Normal file
71
src/pocketmine/network/mcpe/protocol/EntityEventPacket.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class EntityEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ENTITY_EVENT_PACKET;
|
||||
|
||||
const HURT_ANIMATION = 2;
|
||||
const DEATH_ANIMATION = 3;
|
||||
|
||||
const TAME_FAIL = 6;
|
||||
const TAME_SUCCESS = 7;
|
||||
const SHAKE_WET = 8;
|
||||
const USE_ITEM = 9;
|
||||
const EAT_GRASS_ANIMATION = 10;
|
||||
const FISH_HOOK_BUBBLE = 11;
|
||||
const FISH_HOOK_POSITION = 12;
|
||||
const FISH_HOOK_HOOK = 13;
|
||||
const FISH_HOOK_TEASE = 14;
|
||||
const SQUID_INK_CLOUD = 15;
|
||||
const AMBIENT_SOUND = 16;
|
||||
const RESPAWN = 17;
|
||||
|
||||
//TODO add new events
|
||||
|
||||
public $eid;
|
||||
public $event;
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->event = $this->getByte();
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putByte($this->event);
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityEvent($this);
|
||||
}
|
||||
|
||||
}
|
63
src/pocketmine/network/mcpe/protocol/ExplodePacket.php
Normal file
63
src/pocketmine/network/mcpe/protocol/ExplodePacket.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ExplodePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::EXPLODE_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $radius;
|
||||
public $records = [];
|
||||
|
||||
public function clean(){
|
||||
$this->records = [];
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->radius);
|
||||
$this->putUnsignedVarInt(count($this->records));
|
||||
if(count($this->records) > 0){
|
||||
foreach($this->records as $record){
|
||||
$this->putBlockCoords($record->x, $record->y, $record->z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleExplode($this);
|
||||
}
|
||||
|
||||
}
|
51
src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php
Normal file
51
src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class FullChunkDataPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::FULL_CHUNK_DATA_PACKET;
|
||||
|
||||
public $chunkX;
|
||||
public $chunkZ;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->chunkX);
|
||||
$this->putVarInt($this->chunkZ);
|
||||
$this->putString($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleFullChunkData($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class HurtArmorPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
|
||||
|
||||
public $health;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleHurtArmor($this);
|
||||
}
|
||||
|
||||
}
|
55
src/pocketmine/network/mcpe/protocol/InteractPacket.php
Normal file
55
src/pocketmine/network/mcpe/protocol/InteractPacket.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class InteractPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::INTERACT_PACKET;
|
||||
|
||||
const ACTION_RIGHT_CLICK = 1;
|
||||
const ACTION_LEFT_CLICK = 2;
|
||||
const ACTION_LEAVE_VEHICLE = 3;
|
||||
const ACTION_MOUSEOVER = 4;
|
||||
|
||||
public $action;
|
||||
public $target;
|
||||
|
||||
public function decode(){
|
||||
$this->action = $this->getByte();
|
||||
$this->target = $this->getEntityId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->action);
|
||||
$this->putEntityId($this->target);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInteract($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class InventoryActionPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::INVENTORY_ACTION_PACKET;
|
||||
|
||||
public $unknown;
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->putUnsignedVarInt($this->unknown);
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInventoryAction($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ItemFrameDropItemPacket extends DataPacket{
|
||||
|
||||
const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleItemFrameDropItem($this);
|
||||
}
|
||||
|
||||
}
|
116
src/pocketmine/network/mcpe/protocol/LevelEventPacket.php
Normal file
116
src/pocketmine/network/mcpe/protocol/LevelEventPacket.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class LevelEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_PACKET;
|
||||
|
||||
const EVENT_SOUND_CLICK = 1000;
|
||||
const EVENT_SOUND_CLICK_FAIL = 1001;
|
||||
const EVENT_SOUND_SHOOT = 1002;
|
||||
const EVENT_SOUND_DOOR = 1003;
|
||||
const EVENT_SOUND_FIZZ = 1004;
|
||||
const EVENT_SOUND_IGNITE = 1005;
|
||||
|
||||
const EVENT_SOUND_GHAST = 1007;
|
||||
const EVENT_SOUND_GHAST_SHOOT = 1008;
|
||||
const EVENT_SOUND_BLAZE_SHOOT = 1009;
|
||||
const EVENT_SOUND_DOOR_BUMP = 1010;
|
||||
|
||||
const EVENT_SOUND_DOOR_CRASH = 1012;
|
||||
|
||||
const EVENT_SOUND_ENDERMAN_TELEPORT = 1018;
|
||||
|
||||
const EVENT_SOUND_ANVIL_BREAK = 1020;
|
||||
const EVENT_SOUND_ANVIL_USE = 1021;
|
||||
const EVENT_SOUND_ANVIL_FALL = 1022;
|
||||
|
||||
const EVENT_SOUND_POP = 1030;
|
||||
|
||||
const EVENT_SOUND_PORTAL = 1032;
|
||||
|
||||
const EVENT_SOUND_ITEMFRAME_ADD_ITEM = 1040;
|
||||
const EVENT_SOUND_ITEMFRAME_REMOVE = 1041;
|
||||
const EVENT_SOUND_ITEMFRAME_PLACE = 1042;
|
||||
const EVENT_SOUND_ITEMFRAME_REMOVE_ITEM = 1043;
|
||||
const EVENT_SOUND_ITEMFRAME_ROTATE_ITEM = 1044;
|
||||
|
||||
const EVENT_SOUND_CAMERA = 1050;
|
||||
const EVENT_SOUND_ORB = 1051;
|
||||
|
||||
const EVENT_PARTICLE_SHOOT = 2000;
|
||||
const EVENT_PARTICLE_DESTROY = 2001;
|
||||
const EVENT_PARTICLE_SPLASH = 2002;
|
||||
const EVENT_PARTICLE_EYE_DESPAWN = 2003;
|
||||
const EVENT_PARTICLE_SPAWN = 2004;
|
||||
|
||||
const EVENT_GUARDIAN_CURSE = 2006;
|
||||
|
||||
const EVENT_PARTICLE_BLOCK_FORCE_FIELD = 2008;
|
||||
|
||||
const EVENT_START_RAIN = 3001;
|
||||
const EVENT_START_THUNDER = 3002;
|
||||
const EVENT_STOP_RAIN = 3003;
|
||||
const EVENT_STOP_THUNDER = 3004;
|
||||
|
||||
const EVENT_REDSTONE_TRIGGER = 3500;
|
||||
const EVENT_CAULDRON_EXPLODE = 3501;
|
||||
const EVENT_CAULDRON_DYE_ARMOR = 3502;
|
||||
const EVENT_CAULDRON_CLEAN_ARMOR = 3503;
|
||||
const EVENT_CAULDRON_FILL_POTION = 3504;
|
||||
const EVENT_CAULDRON_TAKE_POTION = 3505;
|
||||
const EVENT_CAULDRON_FILL_WATER = 3506;
|
||||
const EVENT_CAULDRON_TAKE_WATER = 3507;
|
||||
const EVENT_CAULDRON_ADD_DYE = 3508;
|
||||
|
||||
const EVENT_SET_DATA = 4000;
|
||||
|
||||
const EVENT_PLAYERS_SLEEPING = 9800;
|
||||
|
||||
const EVENT_ADD_PARTICLE_MASK = 0x4000;
|
||||
|
||||
public $evid;
|
||||
public $x = 0; //Weather effects don't have coordinates
|
||||
public $y = 0;
|
||||
public $z = 0;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->evid);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLevelEvent($this);
|
||||
}
|
||||
|
||||
}
|
155
src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php
Normal file
155
src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class LevelSoundEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET;
|
||||
|
||||
const SOUND_ITEM_USE_ON = 0;
|
||||
const SOUND_HIT = 1;
|
||||
const SOUND_STEP = 2;
|
||||
const SOUND_JUMP = 3;
|
||||
const SOUND_BREAK = 4;
|
||||
const SOUND_PLACE = 5;
|
||||
const SOUND_HEAVY_STEP = 6;
|
||||
const SOUND_GALLOP = 7;
|
||||
const SOUND_FALL = 8;
|
||||
const SOUND_AMBIENT = 9;
|
||||
const SOUND_AMBIENT_BABY = 10;
|
||||
const SOUND_AMBIENT_IN_WATER = 11;
|
||||
const SOUND_BREATHE = 12;
|
||||
const SOUND_DEATH = 13;
|
||||
const SOUND_DEATH_IN_WATER = 14;
|
||||
const SOUND_DEATH_TO_ZOMBIE = 15;
|
||||
const SOUND_HURT = 16;
|
||||
const SOUND_HURT_IN_WATER = 17;
|
||||
const SOUND_MAD = 18;
|
||||
const SOUND_BOOST = 19;
|
||||
const SOUND_BOW = 20;
|
||||
const SOUND_SQUISH_BIG = 21;
|
||||
const SOUND_SQUISH_SMALL = 22;
|
||||
const SOUND_FALL_BIG = 23;
|
||||
const SOUND_FALL_SMALL = 24;
|
||||
const SOUND_SPLASH = 25;
|
||||
const SOUND_FIZZ = 26;
|
||||
const SOUND_FLAP = 27;
|
||||
const SOUND_SWIM = 28;
|
||||
const SOUND_DRINK = 29;
|
||||
const SOUND_EAT = 30;
|
||||
const SOUND_TAKEOFF = 31;
|
||||
const SOUND_SHAKE = 32;
|
||||
const SOUND_PLOP = 33;
|
||||
const SOUND_LAND = 34;
|
||||
const SOUND_SADDLE = 35;
|
||||
const SOUND_ARMOR = 36;
|
||||
const SOUND_ADD_CHEST = 37;
|
||||
const SOUND_THROW = 38;
|
||||
const SOUND_ATTACK = 39;
|
||||
const SOUND_ATTACK_NODAMAGE = 40;
|
||||
const SOUND_WARN = 41;
|
||||
const SOUND_SHEAR = 42;
|
||||
const SOUND_MILK = 43;
|
||||
const SOUND_THUNDER = 44;
|
||||
const SOUND_EXPLODE = 45;
|
||||
const SOUND_FIRE = 46;
|
||||
const SOUND_IGNITE = 47;
|
||||
const SOUND_FUSE = 48;
|
||||
const SOUND_STARE = 49;
|
||||
const SOUND_SPAWN = 50;
|
||||
const SOUND_SHOOT = 51;
|
||||
const SOUND_BREAK_BLOCK = 52;
|
||||
const SOUND_REMEDY = 53;
|
||||
const SOUND_UNFECT = 54;
|
||||
const SOUND_LEVELUP = 55;
|
||||
const SOUND_BOW_HIT = 56;
|
||||
const SOUND_BULLET_HIT = 57;
|
||||
const SOUND_EXTINGUISH_FIRE = 58;
|
||||
const SOUND_ITEM_FIZZ = 59;
|
||||
const SOUND_CHEST_OPEN = 60;
|
||||
const SOUND_CHEST_CLOSED = 61;
|
||||
const SOUND_POWER_ON = 62;
|
||||
const SOUND_POWER_OFF = 63;
|
||||
const SOUND_ATTACH = 64;
|
||||
const SOUND_DETACH = 65;
|
||||
const SOUND_DENY = 66;
|
||||
const SOUND_TRIPOD = 67;
|
||||
const SOUND_POP = 68;
|
||||
const SOUND_DROP_SLOT = 69;
|
||||
const SOUND_NOTE = 70;
|
||||
const SOUND_THORNS = 71;
|
||||
const SOUND_PISTON_IN = 72;
|
||||
const SOUND_PISTON_OUT = 73;
|
||||
const SOUND_PORTAL = 74;
|
||||
const SOUND_WATER = 75;
|
||||
const SOUND_LAVA_POP = 76;
|
||||
const SOUND_LAVA = 77;
|
||||
const SOUND_BURP = 78;
|
||||
const SOUND_BUCKET_FILL_WATER = 79;
|
||||
const SOUND_BUCKET_FILL_LAVA = 80;
|
||||
const SOUND_BUCKET_EMPTY_WATER = 81;
|
||||
const SOUND_BUCKET_EMPTY_LAVA = 82;
|
||||
const SOUND_GUARDIAN_FLOP = 83;
|
||||
const SOUND_ELDERGUARDIAN_CURSE = 84;
|
||||
const SOUND_MOB_WARNING = 85;
|
||||
const SOUND_MOB_WARNING_BABY = 86;
|
||||
const SOUND_TELEPORT = 87;
|
||||
const SOUND_SHULKER_OPEN = 88;
|
||||
const SOUND_SHULKER_CLOSE = 89;
|
||||
const SOUND_DEFAULT = 90;
|
||||
const SOUND_UNDEFINED = 91;
|
||||
|
||||
public $sound;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $extraData = -1;
|
||||
public $pitch = 1;
|
||||
public $unknownBool = false;
|
||||
public $unknownBool2 = false;
|
||||
|
||||
public function decode(){
|
||||
$this->sound = $this->getByte();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->extraData = $this->getVarInt();
|
||||
$this->pitch = $this->getVarInt();
|
||||
$this->unknownBool = $this->getBool();
|
||||
$this->unknownBool2 = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->sound);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->extraData);
|
||||
$this->putVarInt($this->pitch);
|
||||
$this->putBool($this->unknownBool);
|
||||
$this->putBool($this->unknownBool2);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLevelSoundEvent($this);
|
||||
}
|
||||
}
|
102
src/pocketmine/network/mcpe/protocol/LoginPacket.php
Normal file
102
src/pocketmine/network/mcpe/protocol/LoginPacket.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class LoginPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::LOGIN_PACKET;
|
||||
|
||||
const EDITION_POCKET = 0;
|
||||
|
||||
public $username;
|
||||
public $protocol;
|
||||
public $gameEdition;
|
||||
public $clientUUID;
|
||||
public $clientId;
|
||||
public $identityPublicKey;
|
||||
public $serverAddress;
|
||||
|
||||
public $skinId;
|
||||
public $skin = null;
|
||||
|
||||
public $clientData = [];
|
||||
|
||||
public function decode(){
|
||||
$this->protocol = $this->getInt();
|
||||
|
||||
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
||||
$this->buffer = null;
|
||||
return; //Do not attempt to decode for non-accepted protocols
|
||||
}
|
||||
|
||||
$this->gameEdition = $this->getByte();
|
||||
|
||||
$str = zlib_decode($this->getString(), 1024 * 1024 * 64);
|
||||
|
||||
$this->setBuffer($str, 0);
|
||||
|
||||
$chainData = json_decode($this->get($this->getLInt()));
|
||||
foreach($chainData->{"chain"} as $chain){
|
||||
$webtoken = $this->decodeToken($chain);
|
||||
if(isset($webtoken["extraData"])){
|
||||
if(isset($webtoken["extraData"]["displayName"])){
|
||||
$this->username = $webtoken["extraData"]["displayName"];
|
||||
}
|
||||
if(isset($webtoken["extraData"]["identity"])){
|
||||
$this->clientUUID = $webtoken["extraData"]["identity"];
|
||||
}
|
||||
if(isset($webtoken["identityPublicKey"])){
|
||||
$this->identityPublicKey = $webtoken["identityPublicKey"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->clientData = $this->decodeToken($this->get($this->getLInt()));
|
||||
|
||||
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
||||
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
|
||||
$this->skinId = $this->clientData["SkinId"] ?? null;
|
||||
|
||||
if(isset($this->clientData["SkinData"])){
|
||||
$this->skin = base64_decode($this->clientData["SkinData"]);
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function decodeToken($token){
|
||||
$tokens = explode(".", $token);
|
||||
list($headB64, $payloadB64, $sigB64) = $tokens;
|
||||
|
||||
return json_decode(base64_decode($payloadB64), true);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLogin($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MobArmorEquipmentPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $slots = [];
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->slots[0] = $this->getSlot();
|
||||
$this->slots[1] = $this->getSlot();
|
||||
$this->slots[2] = $this->getSlot();
|
||||
$this->slots[3] = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putSlot($this->slots[0]);
|
||||
$this->putSlot($this->slots[1]);
|
||||
$this->putSlot($this->slots[2]);
|
||||
$this->putSlot($this->slots[3]);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobArmorEquipment($this);
|
||||
}
|
||||
|
||||
}
|
61
src/pocketmine/network/mcpe/protocol/MobEffectPacket.php
Normal file
61
src/pocketmine/network/mcpe/protocol/MobEffectPacket.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MobEffectPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET;
|
||||
|
||||
const EVENT_ADD = 1;
|
||||
const EVENT_MODIFY = 2;
|
||||
const EVENT_REMOVE = 3;
|
||||
|
||||
public $eid;
|
||||
public $eventId;
|
||||
public $effectId;
|
||||
public $amplifier;
|
||||
public $particles = true;
|
||||
public $duration;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putByte($this->eventId);
|
||||
$this->putVarInt($this->effectId);
|
||||
$this->putVarInt($this->amplifier);
|
||||
$this->putBool($this->particles);
|
||||
$this->putVarInt($this->duration);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobEffect($this);
|
||||
}
|
||||
|
||||
}
|
59
src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php
Normal file
59
src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MobEquipmentPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $item;
|
||||
public $slot;
|
||||
public $selectedSlot;
|
||||
public $unknownByte;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId(); //EntityRuntimeID
|
||||
$this->item = $this->getSlot();
|
||||
$this->slot = $this->getByte();
|
||||
$this->selectedSlot = $this->getByte();
|
||||
$this->unknownByte = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putSlot($this->item);
|
||||
$this->putByte($this->slot);
|
||||
$this->putByte($this->selectedSlot);
|
||||
$this->putByte($this->unknownByte);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobEquipment($this);
|
||||
}
|
||||
|
||||
}
|
61
src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php
Normal file
61
src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MoveEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $yaw;
|
||||
public $headYaw;
|
||||
public $pitch;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->pitch = $this->getByte() * (360.0 / 256);
|
||||
$this->yaw = $this->getByte() * (360.0 / 256);
|
||||
$this->headYaw = $this->getByte() * (360.0 / 256);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putByte($this->pitch / (360.0 / 256));
|
||||
$this->putByte($this->yaw / (360.0 / 256));
|
||||
$this->putByte($this->headYaw / (360.0 / 256));
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMoveEntity($this);
|
||||
}
|
||||
|
||||
}
|
71
src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php
Normal file
71
src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MovePlayerPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET;
|
||||
|
||||
const MODE_NORMAL = 0;
|
||||
const MODE_RESET = 1;
|
||||
const MODE_ROTATION = 2;
|
||||
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $yaw;
|
||||
public $bodyYaw;
|
||||
public $pitch;
|
||||
public $mode = self::MODE_NORMAL;
|
||||
public $onGround;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId(); //EntityRuntimeID
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->bodyYaw = $this->getLFloat();
|
||||
$this->mode = $this->getByte();
|
||||
$this->onGround = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->bodyYaw); //TODO
|
||||
$this->putByte($this->mode);
|
||||
$this->putBool($this->onGround);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMovePlayer($this);
|
||||
}
|
||||
|
||||
}
|
54
src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php
Normal file
54
src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlayStatusPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAY_STATUS_PACKET;
|
||||
|
||||
const LOGIN_SUCCESS = 0;
|
||||
const LOGIN_FAILED_CLIENT = 1;
|
||||
const LOGIN_FAILED_SERVER = 2;
|
||||
const PLAYER_SPAWN = 3;
|
||||
const LOGIN_FAILED_INVALID_TENANT = 4;
|
||||
const LOGIN_FAILED_EDITION_MISMATCH = 5;
|
||||
|
||||
public $status;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->status);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayStatus($this);
|
||||
}
|
||||
|
||||
}
|
76
src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php
Normal file
76
src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlayerActionPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAYER_ACTION_PACKET;
|
||||
|
||||
const ACTION_START_BREAK = 0;
|
||||
const ACTION_ABORT_BREAK = 1;
|
||||
const ACTION_STOP_BREAK = 2;
|
||||
|
||||
|
||||
const ACTION_RELEASE_ITEM = 5;
|
||||
const ACTION_STOP_SLEEPING = 6;
|
||||
const ACTION_RESPAWN = 7;
|
||||
const ACTION_JUMP = 8;
|
||||
const ACTION_START_SPRINT = 9;
|
||||
const ACTION_STOP_SPRINT = 10;
|
||||
const ACTION_START_SNEAK = 11;
|
||||
const ACTION_STOP_SNEAK = 12;
|
||||
const ACTION_DIMENSION_CHANGE = 13; //TODO: correct these
|
||||
|
||||
const ACTION_START_GLIDE = 15;
|
||||
const ACTION_STOP_GLIDE = 16;
|
||||
|
||||
public $eid;
|
||||
public $action;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $face;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->action = $this->getVarInt();
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->face = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVarInt($this->action);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->face);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerAction($this);
|
||||
}
|
||||
|
||||
}
|
45
src/pocketmine/network/mcpe/protocol/PlayerFallPacket.php
Normal file
45
src/pocketmine/network/mcpe/protocol/PlayerFallPacket.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlayerFallPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAYER_FALL_PACKET;
|
||||
|
||||
public $fallDistance;
|
||||
|
||||
public function decode(){
|
||||
$this->fallDistance = $this->getLFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerFall($this);
|
||||
}
|
||||
}
|
52
src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php
Normal file
52
src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlayerInputPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET;
|
||||
|
||||
public $motionX;
|
||||
public $motionY;
|
||||
public $unknownBool1;
|
||||
public $unknownBool2;
|
||||
|
||||
public function decode(){
|
||||
$this->motionX = $this->getLFloat();
|
||||
$this->motionY = $this->getLFloat();
|
||||
$this->unknownBool1 = $this->getBool();
|
||||
$this->unknownBool2 = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerInput($this);
|
||||
}
|
||||
|
||||
}
|
70
src/pocketmine/network/mcpe/protocol/PlayerListPacket.php
Normal file
70
src/pocketmine/network/mcpe/protocol/PlayerListPacket.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlayerListPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAYER_LIST_PACKET;
|
||||
|
||||
const TYPE_ADD = 0;
|
||||
const TYPE_REMOVE = 1;
|
||||
|
||||
//REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin
|
||||
/** @var array[] */
|
||||
public $entries = [];
|
||||
public $type;
|
||||
|
||||
public function clean(){
|
||||
$this->entries = [];
|
||||
return parent::clean();
|
||||
}
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->type);
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $d){
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$this->putUUID($d[0]);
|
||||
$this->putEntityId($d[1]);
|
||||
$this->putString($d[2]);
|
||||
$this->putString($d[3]);
|
||||
$this->putString($d[4]);
|
||||
}else{
|
||||
$this->putUUID($d[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerList($this);
|
||||
}
|
||||
|
||||
}
|
120
src/pocketmine/network/mcpe/protocol/ProtocolInfo.php
Normal file
120
src/pocketmine/network/mcpe/protocol/ProtocolInfo.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minecraft: PE multiplayer protocol implementation
|
||||
*/
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
interface ProtocolInfo{
|
||||
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
const CURRENT_PROTOCOL = 101;
|
||||
const MINECRAFT_VERSION = "v1.0.3.0";
|
||||
const MINECRAFT_VERSION_NETWORK = "1.0.3.0";
|
||||
|
||||
const LOGIN_PACKET = 0x01;
|
||||
const PLAY_STATUS_PACKET = 0x02;
|
||||
const SERVER_TO_CLIENT_HANDSHAKE_PACKET = 0x03;
|
||||
const CLIENT_TO_SERVER_HANDSHAKE_PACKET = 0x04;
|
||||
const DISCONNECT_PACKET = 0x05;
|
||||
const BATCH_PACKET = 0x06;
|
||||
const RESOURCE_PACKS_INFO_PACKET = 0x07;
|
||||
const RESOURCE_PACK_STACK_PACKET = 0x08; //ResourcePacksStackPacket
|
||||
const RESOURCE_PACK_CLIENT_RESPONSE_PACKET = 0x09;
|
||||
const TEXT_PACKET = 0x0a;
|
||||
const SET_TIME_PACKET = 0x0b;
|
||||
const START_GAME_PACKET = 0x0c;
|
||||
const ADD_PLAYER_PACKET = 0x0d;
|
||||
const ADD_ENTITY_PACKET = 0x0e;
|
||||
const REMOVE_ENTITY_PACKET = 0x0f;
|
||||
const ADD_ITEM_ENTITY_PACKET = 0x10;
|
||||
const ADD_HANGING_ENTITY_PACKET = 0x11;
|
||||
const TAKE_ITEM_ENTITY_PACKET = 0x12;
|
||||
const MOVE_ENTITY_PACKET = 0x13;
|
||||
const MOVE_PLAYER_PACKET = 0x14;
|
||||
const RIDER_JUMP_PACKET = 0x15;
|
||||
const REMOVE_BLOCK_PACKET = 0x16;
|
||||
const UPDATE_BLOCK_PACKET = 0x17;
|
||||
const ADD_PAINTING_PACKET = 0x18;
|
||||
const EXPLODE_PACKET = 0x19;
|
||||
const LEVEL_SOUND_EVENT_PACKET = 0x1a;
|
||||
const LEVEL_EVENT_PACKET = 0x1b;
|
||||
const BLOCK_EVENT_PACKET = 0x1c;
|
||||
const ENTITY_EVENT_PACKET = 0x1d;
|
||||
const MOB_EFFECT_PACKET = 0x1e;
|
||||
const UPDATE_ATTRIBUTES_PACKET = 0x1f;
|
||||
const MOB_EQUIPMENT_PACKET = 0x20;
|
||||
const MOB_ARMOR_EQUIPMENT_PACKET = 0x21;
|
||||
const INTERACT_PACKET = 0x22;
|
||||
const USE_ITEM_PACKET = 0x23;
|
||||
const PLAYER_ACTION_PACKET = 0x24;
|
||||
const PLAYER_FALL_PACKET = 0x25;
|
||||
const HURT_ARMOR_PACKET = 0x26;
|
||||
const SET_ENTITY_DATA_PACKET = 0x27;
|
||||
const SET_ENTITY_MOTION_PACKET = 0x28;
|
||||
const SET_ENTITY_LINK_PACKET = 0x29;
|
||||
const SET_HEALTH_PACKET = 0x2a;
|
||||
const SET_SPAWN_POSITION_PACKET = 0x2b;
|
||||
const ANIMATE_PACKET = 0x2c;
|
||||
const RESPAWN_PACKET = 0x2d;
|
||||
const DROP_ITEM_PACKET = 0x2e;
|
||||
const INVENTORY_ACTION_PACKET = 0x2f;
|
||||
const CONTAINER_OPEN_PACKET = 0x30;
|
||||
const CONTAINER_CLOSE_PACKET = 0x31;
|
||||
const CONTAINER_SET_SLOT_PACKET = 0x32;
|
||||
const CONTAINER_SET_DATA_PACKET = 0x33;
|
||||
const CONTAINER_SET_CONTENT_PACKET = 0x34;
|
||||
const CRAFTING_DATA_PACKET = 0x35;
|
||||
const CRAFTING_EVENT_PACKET = 0x36;
|
||||
const ADVENTURE_SETTINGS_PACKET = 0x37;
|
||||
const BLOCK_ENTITY_DATA_PACKET = 0x38;
|
||||
const PLAYER_INPUT_PACKET = 0x39;
|
||||
const FULL_CHUNK_DATA_PACKET = 0x3a;
|
||||
const SET_COMMANDS_ENABLED_PACKET = 0x3b;
|
||||
const SET_DIFFICULTY_PACKET = 0x3c;
|
||||
const CHANGE_DIMENSION_PACKET = 0x3d;
|
||||
const SET_PLAYER_GAME_TYPE_PACKET = 0x3e;
|
||||
const PLAYER_LIST_PACKET = 0x3f;
|
||||
const EVENT_PACKET = 0x40; //TelemetryEventPacket
|
||||
const SPAWN_EXPERIENCE_ORB_PACKET = 0x41;
|
||||
const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0x42; //MapItemDataPacket
|
||||
const MAP_INFO_REQUEST_PACKET = 0x43;
|
||||
const REQUEST_CHUNK_RADIUS_PACKET = 0x44;
|
||||
const CHUNK_RADIUS_UPDATED_PACKET = 0x45;
|
||||
const ITEM_FRAME_DROP_ITEM_PACKET = 0x46;
|
||||
const REPLACE_ITEM_IN_SLOT_PACKET = 0x47; //ReplaceSelectedItemPacket
|
||||
const GAME_RULES_CHANGED_PACKET = 0x48;
|
||||
const CAMERA_PACKET = 0x49;
|
||||
const ADD_ITEM_PACKET = 0x4a;
|
||||
const BOSS_EVENT_PACKET = 0x4b;
|
||||
const SHOW_CREDITS_PACKET = 0x4c;
|
||||
const AVAILABLE_COMMANDS_PACKET = 0x4d;
|
||||
const COMMAND_STEP_PACKET = 0x4e;
|
||||
const RESOURCE_PACK_DATA_INFO_PACKET = 0x4f;
|
||||
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x50;
|
||||
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x51;
|
||||
const TRANSFER_PACKET = 0x52;
|
||||
|
||||
}
|
48
src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php
Normal file
48
src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RemoveBlockPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::REMOVE_BLOCK_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRemoveBlock($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RemoveEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET;
|
||||
|
||||
public $eid;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRemoveEntity($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ReplaceItemInSlotPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::REPLACE_ITEM_IN_SLOT_PACKET;
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleReplaceItemInSlot($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RequestChunkRadiusPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET;
|
||||
|
||||
public $radius;
|
||||
|
||||
public function decode(){
|
||||
$this->radius = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRequestChunkRadius($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ResourcePackClientResponsePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET;
|
||||
|
||||
const STATUS_REFUSED = 1;
|
||||
const STATUS_SEND_PACKS = 2;
|
||||
const STATUS_HAVE_ALL_PACKS = 3;
|
||||
const STATUS_COMPLETED = 4;
|
||||
|
||||
public $status; //TODO: add constants for status types
|
||||
public $packIds = [];
|
||||
|
||||
public function decode(){
|
||||
$this->status = $this->getByte();
|
||||
$entryCount = $this->getLShort();
|
||||
while($entryCount-- > 0){
|
||||
$this->packIds[] = $this->getString();
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->status);
|
||||
$this->putLShort(count($this->packIds));
|
||||
foreach($this->packIds as $id){
|
||||
$this->putString($id);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackClientResponse($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\resourcepacks\ResourcePackInfoEntry;
|
||||
|
||||
class ResourcePackStackPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET;
|
||||
|
||||
public $mustAccept = false;
|
||||
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $behaviorPackStack = [];
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $resourcePackStack = [];
|
||||
|
||||
public function decode(){
|
||||
$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getLShort();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$packId = $this->getString();
|
||||
$version = $this->getString();
|
||||
$this->behaviorPackStack[] = new ResourcePackInfoEntry($packId, $version);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->getLShort();
|
||||
while($resourcePackCount-- > 0){
|
||||
$packId = $this->getString();
|
||||
$version = $this->getString();
|
||||
$this->resourcePackStack[] = new ResourcePackInfoEntry($packId, $version);
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBool($this->mustAccept);
|
||||
|
||||
$this->putLShort(count($this->behaviorPackStack));
|
||||
foreach($this->behaviorPackStack as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
}
|
||||
|
||||
$this->putLShort(count($this->resourcePackStack));
|
||||
foreach($this->resourcePackStack as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackStack($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\resourcepacks\ResourcePackInfoEntry;
|
||||
|
||||
class ResourcePacksInfoPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET;
|
||||
|
||||
public $mustAccept = false; //if true, forces client to use selected resource packs
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $behaviorPackEntries = [];
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $resourcePackEntries = [];
|
||||
|
||||
public function decode(){
|
||||
$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getLShort();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$id = $this->getString();
|
||||
$version = $this->getString();
|
||||
$size = $this->getLLong();
|
||||
$this->behaviorPackEntries[] = new ResourcePackInfoEntry($id, $version, $size);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->getLShort();
|
||||
while($resourcePackCount-- > 0){
|
||||
$id = $this->getString();
|
||||
$version = $this->getString();
|
||||
$size = $this->getLLong();
|
||||
$this->resourcePackEntries[] = new ResourcePackInfoEntry($id, $version, $size);
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
|
||||
$this->putBool($this->mustAccept);
|
||||
$this->putLShort(count($this->behaviorPackEntries));
|
||||
foreach($this->behaviorPackEntries as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
$this->putLLong($entry->getPackSize());
|
||||
}
|
||||
$this->putLShort(count($this->resourcePackEntries));
|
||||
foreach($this->resourcePackEntries as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
$this->putLLong($entry->getPackSize());
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePacksInfo($this);
|
||||
}
|
||||
}
|
53
src/pocketmine/network/mcpe/protocol/RespawnPacket.php
Normal file
53
src/pocketmine/network/mcpe/protocol/RespawnPacket.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RespawnPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
$this->x = $this->getLFloat();
|
||||
$this->y = $this->getLFloat();
|
||||
$this->z = $this->getLFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLFloat($this->x);
|
||||
$this->putLFloat($this->y);
|
||||
$this->putLFloat($this->z);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRespawn($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RiderJumpPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET;
|
||||
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRiderJump($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetCommandsEnabledPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_COMMANDS_ENABLED_PACKET;
|
||||
|
||||
public $enabled;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBool($this->enabled);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetCommandsEnabled($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetDifficultyPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_DIFFICULTY_PACKET;
|
||||
|
||||
public $difficulty;
|
||||
|
||||
public function decode(){
|
||||
$this->difficulty = $this->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putUnsignedVarInt($this->difficulty);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetDifficulty($this);
|
||||
}
|
||||
|
||||
}
|
48
src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php
Normal file
48
src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetEntityDataPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_ENTITY_DATA_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $metadata;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetEntityData($this);
|
||||
}
|
||||
}
|
51
src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php
Normal file
51
src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetEntityLinkPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_ENTITY_LINK_PACKET;
|
||||
|
||||
public $from;
|
||||
public $to;
|
||||
public $type;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->from);
|
||||
$this->putEntityId($this->to);
|
||||
$this->putByte($this->type);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetEntityLink($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetEntityMotionPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_ENTITY_MOTION_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $motionX;
|
||||
public $motionY;
|
||||
public $motionZ;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetEntityMotion($this);
|
||||
}
|
||||
|
||||
}
|
47
src/pocketmine/network/mcpe/protocol/SetHealthPacket.php
Normal file
47
src/pocketmine/network/mcpe/protocol/SetHealthPacket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetHealthPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_HEALTH_PACKET;
|
||||
|
||||
public $health;
|
||||
|
||||
public function decode(){
|
||||
$this->health = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetHealth($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetPlayerGameTypePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET;
|
||||
|
||||
public $gamemode;
|
||||
|
||||
public function decode(){
|
||||
$this->gamemode = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->gamemode);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetPlayerGameType($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetSpawnPositionPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_SPAWN_POSITION_PACKET;
|
||||
|
||||
public $unknown;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknownBool;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->unknown);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->unknownBool);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetSpawnPosition($this);
|
||||
}
|
||||
|
||||
}
|
48
src/pocketmine/network/mcpe/protocol/SetTimePacket.php
Normal file
48
src/pocketmine/network/mcpe/protocol/SetTimePacket.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetTimePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_TIME_PACKET;
|
||||
|
||||
public $time;
|
||||
public $started = true;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->time);
|
||||
$this->putBool($this->started);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetTime($this);
|
||||
}
|
||||
|
||||
}
|
53
src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php
Normal file
53
src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ShowCreditsPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SHOW_CREDITS_PACKET;
|
||||
|
||||
const STATUS_START_CREDITS = 0;
|
||||
const STATUS_END_CREDITS = 1;
|
||||
|
||||
public $playerEid;
|
||||
public $status;
|
||||
|
||||
public function decode(){
|
||||
$this->playerEid = $this->getEntityId();
|
||||
$this->status = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->playerEid);
|
||||
$this->putVarInt($this->status);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleShowCredits($this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SpawnExperienceOrbPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $amount;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->amount);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSpawnExperienceOrb($this);
|
||||
}
|
||||
}
|
87
src/pocketmine/network/mcpe/protocol/StartGamePacket.php
Normal file
87
src/pocketmine/network/mcpe/protocol/StartGamePacket.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class StartGamePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
|
||||
|
||||
public $entityUniqueId;
|
||||
public $entityRuntimeId;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $seed;
|
||||
public $dimension;
|
||||
public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat
|
||||
public $gamemode;
|
||||
public $difficulty;
|
||||
public $spawnX;
|
||||
public $spawnY;
|
||||
public $spawnZ;
|
||||
public $hasAchievementsDisabled = 1;
|
||||
public $dayCycleStopTime = -1; //-1 = not stopped, any positive value = stopped at that time
|
||||
public $eduMode = 0;
|
||||
public $rainLevel;
|
||||
public $lightningLevel;
|
||||
public $commandsEnabled;
|
||||
public $isTexturePacksRequired = 0;
|
||||
public $levelId = ""; //base64 string, usually the same as world folder name in vanilla
|
||||
public $worldName;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->entityUniqueId); //EntityUniqueID
|
||||
$this->putEntityId($this->entityRuntimeId); //EntityRuntimeID
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putLFloat(0); //TODO: find out what these are (yaw/pitch?)
|
||||
$this->putLFloat(0);
|
||||
$this->putVarInt($this->seed);
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVarInt($this->generator);
|
||||
$this->putVarInt($this->gamemode);
|
||||
$this->putVarInt($this->difficulty);
|
||||
$this->putBlockCoords($this->spawnX, $this->spawnY, $this->spawnZ);
|
||||
$this->putBool($this->hasAchievementsDisabled);
|
||||
$this->putVarInt($this->dayCycleStopTime);
|
||||
$this->putBool($this->eduMode);
|
||||
$this->putLFloat($this->rainLevel);
|
||||
$this->putLFloat($this->lightningLevel);
|
||||
$this->putBool($this->commandsEnabled);
|
||||
$this->putBool($this->isTexturePacksRequired);
|
||||
$this->putString($this->levelId);
|
||||
$this->putString($this->worldName);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleStartGame($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class TakeItemEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::TAKE_ITEM_ENTITY_PACKET;
|
||||
|
||||
public $target;
|
||||
public $eid;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->target);
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleTakeItemEntity($this);
|
||||
}
|
||||
}
|
96
src/pocketmine/network/mcpe/protocol/TextPacket.php
Normal file
96
src/pocketmine/network/mcpe/protocol/TextPacket.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class TextPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::TEXT_PACKET;
|
||||
|
||||
const TYPE_RAW = 0;
|
||||
const TYPE_CHAT = 1;
|
||||
const TYPE_TRANSLATION = 2;
|
||||
const TYPE_POPUP = 3;
|
||||
const TYPE_TIP = 4;
|
||||
const TYPE_SYSTEM = 5;
|
||||
const TYPE_WHISPER = 6;
|
||||
|
||||
public $type;
|
||||
public $source;
|
||||
public $message;
|
||||
public $parameters = [];
|
||||
|
||||
public function decode(){
|
||||
$this->type = $this->getByte();
|
||||
switch($this->type){
|
||||
case self::TYPE_POPUP:
|
||||
case self::TYPE_CHAT:
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_WHISPER:
|
||||
$this->source = $this->getString();
|
||||
case self::TYPE_RAW:
|
||||
case self::TYPE_TIP:
|
||||
case self::TYPE_SYSTEM:
|
||||
$this->message = $this->getString();
|
||||
break;
|
||||
|
||||
case self::TYPE_TRANSLATION:
|
||||
$this->message = $this->getString();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->parameters[] = $this->getString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->type);
|
||||
switch($this->type){
|
||||
case self::TYPE_POPUP:
|
||||
case self::TYPE_CHAT:
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_WHISPER:
|
||||
$this->putString($this->source);
|
||||
case self::TYPE_RAW:
|
||||
case self::TYPE_TIP:
|
||||
case self::TYPE_SYSTEM:
|
||||
$this->putString($this->message);
|
||||
break;
|
||||
|
||||
case self::TYPE_TRANSLATION:
|
||||
$this->putString($this->message);
|
||||
$this->putUnsignedVarInt(count($this->parameters));
|
||||
foreach($this->parameters as $p){
|
||||
$this->putString($p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleText($this);
|
||||
}
|
||||
|
||||
}
|
48
src/pocketmine/network/mcpe/protocol/TransferPacket.php
Normal file
48
src/pocketmine/network/mcpe/protocol/TransferPacket.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class TransferPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::TRANSFER_PACKET;
|
||||
|
||||
public $address;
|
||||
public $port = 19132;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putString($this->address);
|
||||
$this->putLShort($this->port);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleTransfer($this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class UpdateAttributesPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET;
|
||||
|
||||
|
||||
public $entityId;
|
||||
/** @var Attribute[] */
|
||||
public $entries = [];
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->entityId);
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
$this->putLFloat($entry->getMinValue());
|
||||
$this->putLFloat($entry->getMaxValue());
|
||||
$this->putLFloat($entry->getValue());
|
||||
$this->putLFloat($entry->getDefaultValue());
|
||||
$this->putString($entry->getName());
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleUpdateAttributes($this);
|
||||
}
|
||||
|
||||
}
|
63
src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php
Normal file
63
src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class UpdateBlockPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_PACKET;
|
||||
|
||||
const FLAG_NONE = 0b0000;
|
||||
const FLAG_NEIGHBORS = 0b0001;
|
||||
const FLAG_NETWORK = 0b0010;
|
||||
const FLAG_NOGRAPHIC = 0b0100;
|
||||
const FLAG_PRIORITY = 0b1000;
|
||||
|
||||
const FLAG_ALL = (self::FLAG_NEIGHBORS | self::FLAG_NETWORK);
|
||||
const FLAG_ALL_PRIORITY = (self::FLAG_ALL | self::FLAG_PRIORITY);
|
||||
|
||||
public $x;
|
||||
public $z;
|
||||
public $y;
|
||||
public $blockId;
|
||||
public $blockData;
|
||||
public $flags;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->blockId);
|
||||
$this->putUnsignedVarInt(($this->flags << 4) | $this->blockData);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleUpdateBlock($this);
|
||||
}
|
||||
|
||||
}
|
64
src/pocketmine/network/mcpe/protocol/UseItemPacket.php
Normal file
64
src/pocketmine/network/mcpe/protocol/UseItemPacket.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class UseItemPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::USE_ITEM_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $blockId;
|
||||
public $face;
|
||||
public $item;
|
||||
public $fx;
|
||||
public $fy;
|
||||
public $fz;
|
||||
public $posX;
|
||||
public $posY;
|
||||
public $posZ;
|
||||
public $slot;
|
||||
|
||||
public function decode(){
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->blockId = $this->getUnsignedVarInt();
|
||||
$this->face = $this->getVarInt();
|
||||
$this->getVector3f($this->fx, $this->fy, $this->fz);
|
||||
$this->getVector3f($this->posX, $this->posY, $this->posZ);
|
||||
$this->slot = $this->getVarInt();
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleUseItem($this);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user