Start using pocketmine/bedrock-protocol library

This commit is contained in:
Dylan K. Taylor 2021-07-14 20:32:15 +01:00
parent b86d682793
commit a2e2196a90
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
307 changed files with 51 additions and 23572 deletions

View File

@ -34,6 +34,7 @@
"adhocore/json-comment": "^1.1",
"mdanter/ecc": "^1.0",
"netresearch/jsonmapper": "^4.0",
"pocketmine/bedrock-protocol": "dev-master#88ae308a03e8e61ccfdddd42623efabe9e772b42",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "dev-master",

51
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5456f8b834ba877a4c04d1cf5a933d63",
"content-hash": "4748ce46dd62b80f9a89791d7601b57f",
"packages": [
{
"name": "adhocore/json-comment",
@ -319,6 +319,54 @@
},
"time": "2020-12-01T19:48:11+00:00"
},
{
"name": "pocketmine/bedrock-protocol",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "88ae308a03e8e61ccfdddd42623efabe9e772b42"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/88ae308a03e8e61ccfdddd42623efabe9e772b42",
"reference": "88ae308a03e8e61ccfdddd42623efabe9e772b42",
"shasum": ""
},
"require": {
"ext-json": "*",
"netresearch/jsonmapper": "^4.0",
"php": "^7.4 || ^8.0",
"pocketmine/binaryutils": "^0.2.0",
"pocketmine/color": "^0.2.0",
"pocketmine/math": "^0.3.0",
"pocketmine/nbt": "^0.3.0",
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpstan/phpstan": "0.12.92",
"phpstan/phpstan-phpunit": "^0.12.21",
"phpstan/phpstan-strict-rules": "^0.12.10",
"phpunit/phpunit": "^9.5"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\network\\mcpe\\protocol\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/master"
},
"time": "2021-07-14T19:29:34+00:00"
},
{
"name": "pocketmine/binaryutils",
"version": "0.2.1",
@ -3547,6 +3595,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"pocketmine/bedrock-protocol": 20,
"pocketmine/classloader": 20,
"pocketmine/spl": 20
},

View File

@ -1,124 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ActorEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ACTOR_EVENT_PACKET;
public const JUMP = 1;
public const HURT_ANIMATION = 2;
public const DEATH_ANIMATION = 3;
public const ARM_SWING = 4;
public const STOP_ATTACK = 5;
public const TAME_FAIL = 6;
public const TAME_SUCCESS = 7;
public const SHAKE_WET = 8;
public const USE_ITEM = 9;
public const EAT_GRASS_ANIMATION = 10;
public const FISH_HOOK_BUBBLE = 11;
public const FISH_HOOK_POSITION = 12;
public const FISH_HOOK_HOOK = 13;
public const FISH_HOOK_TEASE = 14;
public const SQUID_INK_CLOUD = 15;
public const ZOMBIE_VILLAGER_CURE = 16;
public const RESPAWN = 18;
public const IRON_GOLEM_OFFER_FLOWER = 19;
public const IRON_GOLEM_WITHDRAW_FLOWER = 20;
public const LOVE_PARTICLES = 21; //breeding
public const VILLAGER_ANGRY = 22;
public const VILLAGER_HAPPY = 23;
public const WITCH_SPELL_PARTICLES = 24;
public const FIREWORK_PARTICLES = 25;
public const IN_LOVE_PARTICLES = 26;
public const SILVERFISH_SPAWN_ANIMATION = 27;
public const GUARDIAN_ATTACK = 28;
public const WITCH_DRINK_POTION = 29;
public const WITCH_THROW_POTION = 30;
public const MINECART_TNT_PRIME_FUSE = 31;
public const CREEPER_PRIME_FUSE = 32;
public const AIR_SUPPLY_EXPIRED = 33;
public const PLAYER_ADD_XP_LEVELS = 34;
public const ELDER_GUARDIAN_CURSE = 35;
public const AGENT_ARM_SWING = 36;
public const ENDER_DRAGON_DEATH = 37;
public const DUST_PARTICLES = 38; //not sure what this is
public const ARROW_SHAKE = 39;
public const EATING_ITEM = 57;
public const BABY_ANIMAL_FEED = 60; //green particles, like bonemeal on crops
public const DEATH_SMOKE_CLOUD = 61;
public const COMPLETE_TRADE = 62;
public const REMOVE_LEASH = 63; //data 1 = cut leash
public const CONSUME_TOTEM = 65;
public const PLAYER_CHECK_TREASURE_HUNTER_ACHIEVEMENT = 66; //mojang...
public const ENTITY_SPAWN = 67; //used for MinecraftEventing stuff, not needed
public const DRAGON_PUKE = 68; //they call this puke particles
public const ITEM_ENTITY_MERGE = 69;
public const START_SWIM = 70;
public const BALLOON_POP = 71;
public const TREASURE_HUNT = 72;
public const AGENT_SUMMON = 73;
public const CHARGED_CROSSBOW = 74;
public const FALL = 75;
//TODO: add more events
/** @var int */
public $entityRuntimeId;
/** @var int */
public $event;
/** @var int */
public $data = 0;
public static function create(int $entityRuntimeId, int $eventId, int $eventData) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->event = $eventId;
$result->data = $eventData;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->event = $in->getByte();
$this->data = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putByte($this->event);
$out->putVarInt($this->data);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleActorEvent($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ACTOR_PICK_REQUEST_PACKET;
/** @var int */
public $entityUniqueId;
/** @var int */
public $hotbarSlot;
protected function decodePayload(PacketSerializer $in) : void{
$this->entityUniqueId = $in->getLLong();
$this->hotbarSlot = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLLong($this->entityUniqueId);
$out->putByte($this->hotbarSlot);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleActorPickRequest($this);
}
}

View File

@ -1,119 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\entity\Attribute;
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
use function count;
class AddActorPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_ACTOR_PACKET;
/** @var int|null */
public $entityUniqueId = null; //TODO
/** @var int */
public $entityRuntimeId;
/** @var string */
public $type;
/** @var Vector3 */
public $position;
/** @var Vector3|null */
public $motion;
/** @var float */
public $pitch = 0.0;
/** @var float */
public $yaw = 0.0;
/** @var float */
public $headYaw = 0.0;
/** @var Attribute[] */
public $attributes = [];
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
/** @var EntityLink[] */
public $links = [];
protected function decodePayload(PacketSerializer $in) : void{
$this->entityUniqueId = $in->getEntityUniqueId();
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->type = $in->getString();
$this->position = $in->getVector3();
$this->motion = $in->getVector3();
$this->pitch = $in->getLFloat();
$this->yaw = $in->getLFloat();
$this->headYaw = $in->getLFloat();
$attrCount = $in->getUnsignedVarInt();
for($i = 0; $i < $attrCount; ++$i){
$id = $in->getString();
$min = $in->getLFloat();
$current = $in->getLFloat();
$max = $in->getLFloat();
$this->attributes[] = new Attribute($id, $min, $max, $current, $current);
}
$this->metadata = $in->getEntityMetadata();
$linkCount = $in->getUnsignedVarInt();
for($i = 0; $i < $linkCount; ++$i){
$this->links[] = $in->getEntityLink();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putString($this->type);
$out->putVector3($this->position);
$out->putVector3Nullable($this->motion);
$out->putLFloat($this->pitch);
$out->putLFloat($this->yaw);
$out->putLFloat($this->headYaw);
$out->putUnsignedVarInt(count($this->attributes));
foreach($this->attributes as $attribute){
$out->putString($attribute->getId());
$out->putLFloat($attribute->getMin());
$out->putLFloat($attribute->getCurrent());
$out->putLFloat($attribute->getMax());
}
$out->putEntityMetadata($this->metadata);
$out->putUnsignedVarInt(count($this->links));
foreach($this->links as $link){
$out->putEntityLink($link);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddActor($this);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET;
/** @var string */
public $behaviorTreeJson;
protected function decodePayload(PacketSerializer $in) : void{
$this->behaviorTreeJson = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->behaviorTreeJson);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddBehaviorTree($this);
}
}

View File

@ -1,57 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AddEntityPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
/** @var int */
private $entityNetId;
public static function create(int $entityNetId) : self{
$result = new self;
$result->entityNetId = $entityNetId;
return $result;
}
public function getEntityNetId() : int{
return $this->entityNetId;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityNetId = $in->getUnsignedVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->entityNetId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddEntity($this);
}
}

View File

@ -1,77 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
class AddItemActorPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET;
/** @var int|null */
public $entityUniqueId = null; //TODO
/** @var int */
public $entityRuntimeId;
/** @var ItemStackWrapper */
public $item;
/** @var Vector3 */
public $position;
/** @var Vector3|null */
public $motion;
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
/** @var bool */
public $isFromFishing = false;
protected function decodePayload(PacketSerializer $in) : void{
$this->entityUniqueId = $in->getEntityUniqueId();
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->item = ItemStackWrapper::read($in);
$this->position = $in->getVector3();
$this->motion = $in->getVector3();
$this->metadata = $in->getEntityMetadata();
$this->isFromFishing = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$out->putEntityRuntimeId($this->entityRuntimeId);
$this->item->write($out);
$out->putVector3($this->position);
$out->putVector3Nullable($this->motion);
$out->putEntityMetadata($this->metadata);
$out->putBool($this->isFromFishing);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddItemActor($this);
}
}

View File

@ -1,64 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AddPaintingPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
/** @var int|null */
public $entityUniqueId = null;
/** @var int */
public $entityRuntimeId;
/** @var Vector3 */
public $position;
/** @var int */
public $direction;
/** @var string */
public $title;
protected function decodePayload(PacketSerializer $in) : void{
$this->entityUniqueId = $in->getEntityUniqueId();
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->position = $in->getVector3();
$this->direction = $in->getVarInt();
$this->title = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putVector3($this->position);
$out->putVarInt($this->direction);
$out->putString($this->title);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddPainting($this);
}
}

View File

@ -1,156 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\DeviceOS;
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use Ramsey\Uuid\UuidInterface;
use function count;
class AddPlayerPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_PLAYER_PACKET;
/** @var UuidInterface */
public $uuid;
/** @var string */
public $username;
/** @var int|null */
public $entityUniqueId = null; //TODO
/** @var int */
public $entityRuntimeId;
/** @var string */
public $platformChatId = "";
/** @var Vector3 */
public $position;
/** @var Vector3|null */
public $motion;
/** @var float */
public $pitch = 0.0;
/** @var float */
public $yaw = 0.0;
/** @var float|null */
public $headYaw = null; //TODO
/** @var ItemStackWrapper */
public $item;
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
//TODO: adventure settings stuff
/** @var int */
public $uvarint1 = 0;
/** @var int */
public $uvarint2 = 0;
/** @var int */
public $uvarint3 = 0;
/** @var int */
public $uvarint4 = 0;
/** @var int */
public $uvarint5 = 0;
/** @var int */
public $long1 = 0;
/** @var EntityLink[] */
public $links = [];
/** @var string */
public $deviceId = ""; //TODO: fill player's device ID (???)
/** @var int */
public $buildPlatform = DeviceOS::UNKNOWN;
protected function decodePayload(PacketSerializer $in) : void{
$this->uuid = $in->getUUID();
$this->username = $in->getString();
$this->entityUniqueId = $in->getEntityUniqueId();
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->platformChatId = $in->getString();
$this->position = $in->getVector3();
$this->motion = $in->getVector3();
$this->pitch = $in->getLFloat();
$this->yaw = $in->getLFloat();
$this->headYaw = $in->getLFloat();
$this->item = ItemStackWrapper::read($in);
$this->metadata = $in->getEntityMetadata();
$this->uvarint1 = $in->getUnsignedVarInt();
$this->uvarint2 = $in->getUnsignedVarInt();
$this->uvarint3 = $in->getUnsignedVarInt();
$this->uvarint4 = $in->getUnsignedVarInt();
$this->uvarint5 = $in->getUnsignedVarInt();
$this->long1 = $in->getLLong();
$linkCount = $in->getUnsignedVarInt();
for($i = 0; $i < $linkCount; ++$i){
$this->links[$i] = $in->getEntityLink();
}
$this->deviceId = $in->getString();
$this->buildPlatform = $in->getLInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUUID($this->uuid);
$out->putString($this->username);
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putString($this->platformChatId);
$out->putVector3($this->position);
$out->putVector3Nullable($this->motion);
$out->putLFloat($this->pitch);
$out->putLFloat($this->yaw);
$out->putLFloat($this->headYaw ?? $this->yaw);
$this->item->write($out);
$out->putEntityMetadata($this->metadata);
$out->putUnsignedVarInt($this->uvarint1);
$out->putUnsignedVarInt($this->uvarint2);
$out->putUnsignedVarInt($this->uvarint3);
$out->putUnsignedVarInt($this->uvarint4);
$out->putUnsignedVarInt($this->uvarint5);
$out->putLLong($this->long1);
$out->putUnsignedVarInt(count($this->links));
foreach($this->links as $link){
$out->putEntityLink($link);
}
$out->putString($this->deviceId);
$out->putLInt($this->buildPlatform);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddPlayer($this);
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\TreeRoot;
use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AddVolumeEntityPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_VOLUME_ENTITY_PACKET;
/** @var int */
private $entityNetId;
/** @var CompoundTag */
private $data;
public static function create(int $entityNetId, CompoundTag $data) : self{
$result = new self;
$result->entityNetId = $entityNetId;
$result->data = $data;
return $result;
}
public function getEntityNetId() : int{ return $this->entityNetId; }
public function getData() : CompoundTag{ return $this->data; }
protected function decodePayload(PacketSerializer $in) : void{
$this->entityNetId = $in->getUnsignedVarInt();
$this->data = $in->getNbtCompoundRoot();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->entityNetId);
$out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->data)));
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAddVolumeEntity($this);
}
}

View File

@ -1,123 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
public const PERMISSION_NORMAL = 0;
public const PERMISSION_OPERATOR = 1;
public const PERMISSION_HOST = 2;
public const PERMISSION_AUTOMATION = 3;
public const PERMISSION_ADMIN = 4;
/**
* This constant is used to identify flags that should be set on the second field. In a sensible world, these
* flags would all be set on the same packet field, but as of MCPE 1.2, the new abilities flags have for some
* reason been assigned a separate field.
*/
public const BITFLAG_SECOND_SET = 1 << 16;
public const WORLD_IMMUTABLE = 0x01;
public const NO_PVP = 0x02;
public const AUTO_JUMP = 0x20;
public const ALLOW_FLIGHT = 0x40;
public const NO_CLIP = 0x80;
public const WORLD_BUILDER = 0x100;
public const FLYING = 0x200;
public const MUTED = 0x400;
public const MINE = 0x01 | self::BITFLAG_SECOND_SET;
public const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET;
public const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET;
public const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET;
public const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET;
public const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET;
public const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET;
public const BUILD = 0x100 | self::BITFLAG_SECOND_SET;
public const DEFAULT = 0x200 | self::BITFLAG_SECOND_SET;
/** @var int */
public $flags = 0;
/** @var int */
public $commandPermission = self::PERMISSION_NORMAL;
/** @var int */
public $flags2 = -1;
/** @var int */
public $playerPermission = PlayerPermissions::MEMBER;
/** @var int */
public $customFlags = 0; //...
/** @var int */
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
protected function decodePayload(PacketSerializer $in) : void{
$this->flags = $in->getUnsignedVarInt();
$this->commandPermission = $in->getUnsignedVarInt();
$this->flags2 = $in->getUnsignedVarInt();
$this->playerPermission = $in->getUnsignedVarInt();
$this->customFlags = $in->getUnsignedVarInt();
$this->entityUniqueId = $in->getLLong();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->flags);
$out->putUnsignedVarInt($this->commandPermission);
$out->putUnsignedVarInt($this->flags2);
$out->putUnsignedVarInt($this->playerPermission);
$out->putUnsignedVarInt($this->customFlags);
$out->putLLong($this->entityUniqueId);
}
public function getFlag(int $flag) : bool{
if(($flag & self::BITFLAG_SECOND_SET) !== 0){
return ($this->flags2 & $flag) !== 0;
}
return ($this->flags & $flag) !== 0;
}
public function setFlag(int $flag, bool $value) : void{
if(($flag & self::BITFLAG_SECOND_SET) !== 0){
$flagSet =& $this->flags2;
}else{
$flagSet =& $this->flags;
}
if($value){
$flagSet |= $flag;
}else{
$flagSet &= ~$flag;
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAdventureSettings($this);
}
}

View File

@ -1,108 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use function count;
class AnimateEntityPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ANIMATE_ENTITY_PACKET;
/** @var string */
private $animation;
/** @var string */
private $nextState;
/** @var string */
private $stopExpression;
/** @var string */
private $controller;
/** @var float */
private $blendOutTime;
/**
* @var int[]
* @phpstan-var list<int>
*/
private $actorRuntimeIds;
/**
* @param int[] $actorRuntimeIds
* @phpstan-param list<int> $actorRuntimeIds
*/
public static function create(string $animation, string $nextState, string $stopExpression, string $controller, float $blendOutTime, array $actorRuntimeIds) : self{
$result = new self;
$result->animation = $animation;
$result->nextState = $nextState;
$result->stopExpression = $stopExpression;
$result->controller = $controller;
$result->blendOutTime = $blendOutTime;
$result->actorRuntimeIds = $actorRuntimeIds;
return $result;
}
public function getAnimation() : string{ return $this->animation; }
public function getNextState() : string{ return $this->nextState; }
public function getStopExpression() : string{ return $this->stopExpression; }
public function getController() : string{ return $this->controller; }
public function getBlendOutTime() : float{ return $this->blendOutTime; }
/**
* @return int[]
* @phpstan-return list<int>
*/
public function getActorRuntimeIds() : array{ return $this->actorRuntimeIds; }
protected function decodePayload(PacketSerializer $in) : void{
$this->animation = $in->getString();
$this->nextState = $in->getString();
$this->stopExpression = $in->getString();
$this->controller = $in->getString();
$this->blendOutTime = $in->getLFloat();
$this->actorRuntimeIds = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->actorRuntimeIds[] = $in->getEntityRuntimeId();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->animation);
$out->putString($this->nextState);
$out->putString($this->stopExpression);
$out->putString($this->controller);
$out->putLFloat($this->blendOutTime);
$out->putUnsignedVarInt(count($this->actorRuntimeIds));
foreach($this->actorRuntimeIds as $id){
$out->putEntityRuntimeId($id);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAnimateEntity($this);
}
}

View File

@ -1,80 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AnimatePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET;
public const ACTION_SWING_ARM = 1;
public const ACTION_STOP_SLEEP = 3;
public const ACTION_CRITICAL_HIT = 4;
public const ACTION_MAGICAL_CRITICAL_HIT = 5;
public const ACTION_ROW_RIGHT = 128;
public const ACTION_ROW_LEFT = 129;
/** @var int */
public $action;
/** @var int */
public $entityRuntimeId;
/** @var float */
public $float = 0.0; //TODO (Boat rowing time?)
public static function create(int $entityRuntimeId, int $actionId) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->action = $actionId;
return $result;
}
public static function boatHack(int $entityRuntimeId, int $actionId, float $data) : self{
$result = self::create($entityRuntimeId, $actionId);
$result->float = $data;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->action = $in->getVarInt();
$this->entityRuntimeId = $in->getEntityRuntimeId();
if(($this->action & 0x80) !== 0){
$this->float = $in->getLFloat();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->action);
$out->putEntityRuntimeId($this->entityRuntimeId);
if(($this->action & 0x80) !== 0){
$out->putLFloat($this->float);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAnimate($this);
}
}

View File

@ -1,78 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AnvilDamagePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET;
/** @var int */
private $x;
/** @var int */
private $y;
/** @var int */
private $z;
/** @var int */
private $damageAmount;
public static function create(int $x, int $y, int $z, int $damageAmount) : self{
$result = new self;
[$result->x, $result->y, $result->z] = [$x, $y, $z];
$result->damageAmount = $damageAmount;
return $result;
}
public function getDamageAmount() : int{
return $this->damageAmount;
}
public function getX() : int{
return $this->x;
}
public function getY() : int{
return $this->y;
}
public function getZ() : int{
return $this->z;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->damageAmount = $in->getByte();
$in->getBlockPosition($this->x, $this->y, $this->z);
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->damageAmount);
$out->putBlockPosition($this->x, $this->y, $this->z);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAnvilDamage($this);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class AutomationClientConnectPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::AUTOMATION_CLIENT_CONNECT_PACKET;
/** @var string */
public $serverUri;
protected function decodePayload(PacketSerializer $in) : void{
$this->serverUri = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->serverUri);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAutomationClientConnect($this);
}
}

View File

@ -1,60 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
class AvailableActorIdentifiersPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::AVAILABLE_ACTOR_IDENTIFIERS_PACKET;
/**
* @var CacheableNbt
* @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
*/
public $identifiers;
/**
* @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt
*/
public static function create(CacheableNbt $nbt) : self{
$result = new self;
$result->identifiers = $nbt;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->identifiers = new CacheableNbt($in->getNbtCompoundRoot());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->put($this->identifiers->getEncodedNbt());
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAvailableActorIdentifiers($this);
}
}

View File

@ -1,487 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\command\CommandData;
use pocketmine\network\mcpe\protocol\types\command\CommandEnum;
use pocketmine\network\mcpe\protocol\types\command\CommandEnumConstraint;
use pocketmine\network\mcpe\protocol\types\command\CommandParameter;
use pocketmine\utils\BinaryDataException;
use function array_search;
use function count;
use function dechex;
class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::AVAILABLE_COMMANDS_PACKET;
/**
* This flag is set on all types EXCEPT the POSTFIX type. Not completely sure what this is for, but it is required
* for the argtype to work correctly. VALID seems as good a name as any.
*/
public const ARG_FLAG_VALID = 0x100000;
/**
* Basic parameter types. These must be combined with the ARG_FLAG_VALID constant.
* ARG_FLAG_VALID | (type const)
*/
public const ARG_TYPE_INT = 0x01;
public const ARG_TYPE_FLOAT = 0x03;
public const ARG_TYPE_VALUE = 0x04;
public const ARG_TYPE_WILDCARD_INT = 0x05;
public const ARG_TYPE_OPERATOR = 0x06;
public const ARG_TYPE_TARGET = 0x07;
public const ARG_TYPE_WILDCARD_TARGET = 0x08;
public const ARG_TYPE_FILEPATH = 0x10;
public const ARG_TYPE_STRING = 0x20;
public const ARG_TYPE_POSITION = 0x28;
public const ARG_TYPE_MESSAGE = 0x2c;
public const ARG_TYPE_RAWTEXT = 0x2e;
public const ARG_TYPE_JSON = 0x32;
public const ARG_TYPE_COMMAND = 0x3f;
/**
* Enums are a little different: they are composed as follows:
* ARG_FLAG_ENUM | ARG_FLAG_VALID | (enum index)
*/
public const ARG_FLAG_ENUM = 0x200000;
/** This is used for /xp <level: int>L. It can only be applied to integer parameters. */
public const ARG_FLAG_POSTFIX = 0x1000000;
public const HARDCODED_ENUM_NAMES = [
"CommandName" => true
];
/**
* @var CommandData[]
* List of command data, including name, description, alias indexes and parameters.
*/
public $commandData = [];
/**
* @var CommandEnum[]
* List of enums which aren't directly referenced by any vanilla command.
* This is used for the `CommandName` enum, which is a magic enum used by the `command` argument type.
*/
public $hardcodedEnums = [];
/**
* @var CommandEnum[]
* List of dynamic command enums, also referred to as "soft" enums. These can by dynamically updated mid-game
* without resending this packet.
*/
public $softEnums = [];
/**
* @var CommandEnumConstraint[]
* List of constraints for enum members. Used to constrain gamerules that can bechanged in nocheats mode and more.
*/
public $enumConstraints = [];
protected function decodePayload(PacketSerializer $in) : void{
/** @var string[] $enumValues */
$enumValues = [];
for($i = 0, $enumValuesCount = $in->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
$enumValues[] = $in->getString();
}
/** @var string[] $postfixes */
$postfixes = [];
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$postfixes[] = $in->getString();
}
/** @var CommandEnum[] $enums */
$enums = [];
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$enums[] = $enum = $this->getEnum($enumValues, $in);
if(isset(self::HARDCODED_ENUM_NAMES[$enum->getName()])){
$this->hardcodedEnums[] = $enum;
}
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$this->commandData[] = $this->getCommandData($enums, $postfixes, $in);
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$this->softEnums[] = $this->getSoftEnum($in);
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues, $in);
}
}
/**
* @param string[] $enumValueList
*
* @throws PacketDecodeException
* @throws BinaryDataException
*/
protected function getEnum(array $enumValueList, PacketSerializer $in) : CommandEnum{
$enumName = $in->getString();
$enumValues = [];
$listSize = count($enumValueList);
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$index = $this->getEnumValueIndex($listSize, $in);
if(!isset($enumValueList[$index])){
throw new PacketDecodeException("Invalid enum value index $index");
}
//Get the enum value from the initial pile of mess
$enumValues[] = $enumValueList[$index];
}
return new CommandEnum($enumName, $enumValues);
}
/**
* @throws BinaryDataException
*/
protected function getSoftEnum(PacketSerializer $in) : CommandEnum{
$enumName = $in->getString();
$enumValues = [];
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
//Get the enum value from the initial pile of mess
$enumValues[] = $in->getString();
}
return new CommandEnum($enumName, $enumValues);
}
/**
* @param int[] $enumValueMap
*/
protected function putEnum(CommandEnum $enum, array $enumValueMap, PacketSerializer $out) : void{
$out->putString($enum->getName());
$values = $enum->getValues();
$out->putUnsignedVarInt(count($values));
$listSize = count($enumValueMap);
foreach($values as $value){
$index = $enumValueMap[$value] ?? -1;
if($index === -1){
throw new \InvalidStateException("Enum value '$value' not found");
}
$this->putEnumValueIndex($index, $listSize, $out);
}
}
protected function putSoftEnum(CommandEnum $enum, PacketSerializer $out) : void{
$out->putString($enum->getName());
$values = $enum->getValues();
$out->putUnsignedVarInt(count($values));
foreach($values as $value){
$out->putString($value);
}
}
/**
* @throws BinaryDataException
*/
protected function getEnumValueIndex(int $valueCount, PacketSerializer $in) : int{
if($valueCount < 256){
return $in->getByte();
}elseif($valueCount < 65536){
return $in->getLShort();
}else{
return $in->getLInt();
}
}
protected function putEnumValueIndex(int $index, int $valueCount, PacketSerializer $out) : void{
if($valueCount < 256){
$out->putByte($index);
}elseif($valueCount < 65536){
$out->putLShort($index);
}else{
$out->putLInt($index);
}
}
/**
* @param CommandEnum[] $enums
* @param string[] $enumValues
*
* @throws PacketDecodeException
* @throws BinaryDataException
*/
protected function getEnumConstraint(array $enums, array $enumValues, PacketSerializer $in) : CommandEnumConstraint{
//wtf, what was wrong with an offset inside the enum? :(
$valueIndex = $in->getLInt();
if(!isset($enumValues[$valueIndex])){
throw new PacketDecodeException("Enum constraint refers to unknown enum value index $valueIndex");
}
$enumIndex = $in->getLInt();
if(!isset($enums[$enumIndex])){
throw new PacketDecodeException("Enum constraint refers to unknown enum index $enumIndex");
}
$enum = $enums[$enumIndex];
$valueOffset = array_search($enumValues[$valueIndex], $enum->getValues(), true);
if($valueOffset === false){
throw new PacketDecodeException("Value \"" . $enumValues[$valueIndex] . "\" does not belong to enum \"" . $enum->getName() . "\"");
}
$constraintIds = [];
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$constraintIds[] = $in->getByte();
}
return new CommandEnumConstraint($enum, $valueOffset, $constraintIds);
}
/**
* @param int[] $enumIndexes string enum name -> int index
* @param int[] $enumValueIndexes string value -> int index
*/
protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes, PacketSerializer $out) : void{
$out->putLInt($enumValueIndexes[$constraint->getAffectedValue()]);
$out->putLInt($enumIndexes[$constraint->getEnum()->getName()]);
$out->putUnsignedVarInt(count($constraint->getConstraints()));
foreach($constraint->getConstraints() as $v){
$out->putByte($v);
}
}
/**
* @param CommandEnum[] $enums
* @param string[] $postfixes
*
* @throws PacketDecodeException
* @throws BinaryDataException
*/
protected function getCommandData(array $enums, array $postfixes, PacketSerializer $in) : CommandData{
$name = $in->getString();
$description = $in->getString();
$flags = $in->getLShort();
$permission = $in->getByte();
$aliases = $enums[$in->getLInt()] ?? null;
$overloads = [];
for($overloadIndex = 0, $overloadCount = $in->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
$overloads[$overloadIndex] = [];
for($paramIndex = 0, $paramCount = $in->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
$parameter = new CommandParameter();
$parameter->paramName = $in->getString();
$parameter->paramType = $in->getLInt();
$parameter->isOptional = $in->getBool();
$parameter->flags = $in->getByte();
if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){
$index = ($parameter->paramType & 0xffff);
$parameter->enum = $enums[$index] ?? null;
if($parameter->enum === null){
throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: expected enum at $index, but got none");
}
}elseif(($parameter->paramType & self::ARG_FLAG_POSTFIX) !== 0){
$index = ($parameter->paramType & 0xffff);
$parameter->postfix = $postfixes[$index] ?? null;
if($parameter->postfix === null){
throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: expected postfix at $index, but got none");
}
}elseif(($parameter->paramType & self::ARG_FLAG_VALID) === 0){
throw new PacketDecodeException("deserializing $name parameter $parameter->paramName: Invalid parameter type 0x" . dechex($parameter->paramType));
}
$overloads[$overloadIndex][$paramIndex] = $parameter;
}
}
return new CommandData($name, $description, $flags, $permission, $aliases, $overloads);
}
/**
* @param int[] $enumIndexes string enum name -> int index
* @param int[] $postfixIndexes
*/
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes, PacketSerializer $out) : void{
$out->putString($data->name);
$out->putString($data->description);
$out->putLShort($data->flags);
$out->putByte($data->permission);
if($data->aliases !== null){
$out->putLInt($enumIndexes[$data->aliases->getName()] ?? -1);
}else{
$out->putLInt(-1);
}
$out->putUnsignedVarInt(count($data->overloads));
foreach($data->overloads as $overload){
/** @var CommandParameter[] $overload */
$out->putUnsignedVarInt(count($overload));
foreach($overload as $parameter){
$out->putString($parameter->paramName);
if($parameter->enum !== null){
$type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->getName()] ?? -1);
}elseif($parameter->postfix !== null){
$key = $postfixIndexes[$parameter->postfix] ?? -1;
if($key === -1){
throw new \InvalidStateException("Postfix '$parameter->postfix' not in postfixes array");
}
$type = self::ARG_FLAG_POSTFIX | $key;
}else{
$type = $parameter->paramType;
}
$out->putLInt($type);
$out->putBool($parameter->isOptional);
$out->putByte($parameter->flags);
}
}
}
/**
* @param string[] $postfixes
* @phpstan-param array<int, string> $postfixes
*/
private function argTypeToString(int $argtype, array $postfixes) : string{
if(($argtype & self::ARG_FLAG_VALID) !== 0){
if(($argtype & self::ARG_FLAG_ENUM) !== 0){
return "stringenum (" . ($argtype & 0xffff) . ")";
}
switch($argtype & 0xffff){
case self::ARG_TYPE_INT:
return "int";
case self::ARG_TYPE_FLOAT:
return "float";
case self::ARG_TYPE_VALUE:
return "mixed";
case self::ARG_TYPE_TARGET:
return "target";
case self::ARG_TYPE_STRING:
return "string";
case self::ARG_TYPE_POSITION:
return "xyz";
case self::ARG_TYPE_MESSAGE:
return "message";
case self::ARG_TYPE_RAWTEXT:
return "text";
case self::ARG_TYPE_JSON:
return "json";
case self::ARG_TYPE_COMMAND:
return "command";
}
}elseif(($argtype & self::ARG_FLAG_POSTFIX) !== 0){
$postfix = $postfixes[$argtype & 0xffff];
return "int (postfix $postfix)";
}else{
throw new \UnexpectedValueException("Unknown arg type 0x" . dechex($argtype));
}
return "unknown ($argtype)";
}
protected function encodePayload(PacketSerializer $out) : void{
/** @var int[] $enumValueIndexes */
$enumValueIndexes = [];
/** @var int[] $postfixIndexes */
$postfixIndexes = [];
/** @var int[] $enumIndexes */
$enumIndexes = [];
/** @var CommandEnum[] $enums */
$enums = [];
$addEnumFn = static function(CommandEnum $enum) use (&$enums, &$enumIndexes, &$enumValueIndexes) : void{
if(!isset($enumIndexes[$enum->getName()])){
$enums[$enumIndexes[$enum->getName()] = count($enumIndexes)] = $enum;
}
foreach($enum->getValues() as $str){
$enumValueIndexes[$str] = $enumValueIndexes[$str] ?? count($enumValueIndexes); //latest index
}
};
foreach($this->hardcodedEnums as $enum){
$addEnumFn($enum);
}
foreach($this->commandData as $commandData){
if($commandData->aliases !== null){
$addEnumFn($commandData->aliases);
}
/** @var CommandParameter[] $overload */
foreach($commandData->overloads as $overload){
/** @var CommandParameter $parameter */
foreach($overload as $parameter){
if($parameter->enum !== null){
$addEnumFn($parameter->enum);
}
if($parameter->postfix !== null){
$postfixIndexes[$parameter->postfix] = $postfixIndexes[$parameter->postfix] ?? count($postfixIndexes);
}
}
}
}
$out->putUnsignedVarInt(count($enumValueIndexes));
foreach($enumValueIndexes as $enumValue => $index){
$out->putString((string) $enumValue); //stupid PHP key casting D:
}
$out->putUnsignedVarInt(count($postfixIndexes));
foreach($postfixIndexes as $postfix => $index){
$out->putString((string) $postfix); //stupid PHP key casting D:
}
$out->putUnsignedVarInt(count($enums));
foreach($enums as $enum){
$this->putEnum($enum, $enumValueIndexes, $out);
}
$out->putUnsignedVarInt(count($this->commandData));
foreach($this->commandData as $data){
$this->putCommandData($data, $enumIndexes, $postfixIndexes, $out);
}
$out->putUnsignedVarInt(count($this->softEnums));
foreach($this->softEnums as $enum){
$this->putSoftEnum($enum, $out);
}
$out->putUnsignedVarInt(count($this->enumConstraints));
foreach($this->enumConstraints as $constraint){
$this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes, $out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAvailableCommands($this);
}
}

View File

@ -1,60 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::BIOME_DEFINITION_LIST_PACKET;
/**
* @var CacheableNbt
* @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
*/
public $defs;
/**
* @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt
*/
public static function create(CacheableNbt $nbt) : self{
$result = new self;
$result->defs = $nbt;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->defs = new CacheableNbt($in->getNbtCompoundRoot());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->put($this->defs->getEncodedNbt());
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBiomeDefinitionList($this);
}
}

View File

@ -1,69 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
class BlockActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::BLOCK_ACTOR_DATA_PACKET;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/**
* @var CacheableNbt
* @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
*/
public $namedtag;
/**
* @phpstan-param CacheableNbt<\pocketmine\nbt\tag\CompoundTag> $nbt
*/
public static function create(int $x, int $y, int $z, CacheableNbt $nbt) : self{
$result = new self;
[$result->x, $result->y, $result->z] = [$x, $y, $z];
$result->namedtag = $nbt;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->namedtag = new CacheableNbt($in->getNbtCompoundRoot());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBlockPosition($this->x, $this->y, $this->z);
$out->put($this->namedtag->getEncodedNbt());
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBlockActorData($this);
}
}

View File

@ -1,70 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class BlockEventPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $eventType;
/** @var int */
public $eventData;
public static function create(int $eventId, int $eventData, Vector3 $pos) : self{
$pk = new self;
$pk->eventType = $eventId;
$pk->eventData = $eventData;
$pk->x = $pos->getFloorX();
$pk->y = $pos->getFloorY();
$pk->z = $pos->getFloorZ();
return $pk;
}
protected function decodePayload(PacketSerializer $in) : void{
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->eventType = $in->getVarInt();
$this->eventData = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBlockPosition($this->x, $this->y, $this->z);
$out->putVarInt($this->eventType);
$out->putVarInt($this->eventData);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBlockEvent($this);
}
}

View File

@ -1,59 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
/** @var int */
public $blockX;
/** @var int */
public $blockY;
/** @var int */
public $blockZ;
/** @var bool */
public $addUserData = false;
/** @var int */
public $hotbarSlot;
protected function decodePayload(PacketSerializer $in) : void{
$in->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
$this->addUserData = $in->getBool();
$this->hotbarSlot = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
$out->putBool($this->addUserData);
$out->putByte($this->hotbarSlot);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBlockPickRequest($this);
}
}

View File

@ -1,119 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class BookEditPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET;
public const TYPE_REPLACE_PAGE = 0;
public const TYPE_ADD_PAGE = 1;
public const TYPE_DELETE_PAGE = 2;
public const TYPE_SWAP_PAGES = 3;
public const TYPE_SIGN_BOOK = 4;
/** @var int */
public $type;
/** @var int */
public $inventorySlot;
/** @var int */
public $pageNumber;
/** @var int */
public $secondaryPageNumber;
/** @var string */
public $text;
/** @var string */
public $photoName;
/** @var string */
public $title;
/** @var string */
public $author;
/** @var string */
public $xuid;
protected function decodePayload(PacketSerializer $in) : void{
$this->type = $in->getByte();
$this->inventorySlot = $in->getByte();
switch($this->type){
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$this->pageNumber = $in->getByte();
$this->text = $in->getString();
$this->photoName = $in->getString();
break;
case self::TYPE_DELETE_PAGE:
$this->pageNumber = $in->getByte();
break;
case self::TYPE_SWAP_PAGES:
$this->pageNumber = $in->getByte();
$this->secondaryPageNumber = $in->getByte();
break;
case self::TYPE_SIGN_BOOK:
$this->title = $in->getString();
$this->author = $in->getString();
$this->xuid = $in->getString();
break;
default:
throw new PacketDecodeException("Unknown book edit type $this->type!");
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->type);
$out->putByte($this->inventorySlot);
switch($this->type){
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$out->putByte($this->pageNumber);
$out->putString($this->text);
$out->putString($this->photoName);
break;
case self::TYPE_DELETE_PAGE:
$out->putByte($this->pageNumber);
break;
case self::TYPE_SWAP_PAGES:
$out->putByte($this->pageNumber);
$out->putByte($this->secondaryPageNumber);
break;
case self::TYPE_SIGN_BOOK:
$out->putString($this->title);
$out->putString($this->author);
$out->putString($this->xuid);
break;
default:
throw new \InvalidArgumentException("Unknown book edit type $this->type!");
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBookEdit($this);
}
}

View File

@ -1,184 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class BossEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET;
/* S2C: Shows the boss-bar to the player. */
public const TYPE_SHOW = 0;
/* C2S: Registers a player to a boss fight. */
public const TYPE_REGISTER_PLAYER = 1;
/* S2C: Removes the boss-bar from the client. */
public const TYPE_HIDE = 2;
/* C2S: Unregisters a player from a boss fight. */
public const TYPE_UNREGISTER_PLAYER = 3;
/* S2C: Sets the bar percentage. */
public const TYPE_HEALTH_PERCENT = 4;
/* S2C: Sets title of the bar. */
public const TYPE_TITLE = 5;
/* S2C: Not sure on this. Includes color and overlay fields, plus an unknown short. TODO: check this */
public const TYPE_UNKNOWN_6 = 6;
/* S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. */
public const TYPE_TEXTURE = 7;
/** @var int */
public $bossEid;
/** @var int */
public $eventType;
/** @var int (long) */
public $playerEid;
/** @var float */
public $healthPercent;
/** @var string */
public $title;
/** @var int */
public $unknownShort;
/** @var int */
public $color;
/** @var int */
public $overlay;
private static function base(int $bossEntityUniqueId, int $eventId) : self{
$result = new self;
$result->bossEid = $bossEntityUniqueId;
$result->eventType = $eventId;
return $result;
}
public static function show(int $bossEntityUniqueId, string $title, float $healthPercent, int $unknownShort = 0) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_SHOW);
$result->title = $title;
$result->healthPercent = $healthPercent;
$result->unknownShort = $unknownShort;
$result->color = 0; //hardcoded due to being useless
$result->overlay = 0;
return $result;
}
public static function hide(int $bossEntityUniqueId) : self{
return self::base($bossEntityUniqueId, self::TYPE_HIDE);
}
public static function registerPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_REGISTER_PLAYER);
$result->playerEid = $playerEntityUniqueId;
return $result;
}
public static function unregisterPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_UNREGISTER_PLAYER);
$result->playerEid = $playerEntityUniqueId;
return $result;
}
public static function healthPercent(int $bossEntityUniqueId, float $healthPercent) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_HEALTH_PERCENT);
$result->healthPercent = $healthPercent;
return $result;
}
public static function title(int $bossEntityUniqueId, string $title) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_TITLE);
$result->title = $title;
return $result;
}
public static function unknown6(int $bossEntityUniqueId, int $unknownShort) : self{
$result = self::base($bossEntityUniqueId, self::TYPE_UNKNOWN_6);
$result->unknownShort = $unknownShort;
$result->color = 0; //hardcoded due to being useless
$result->overlay = 0;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->bossEid = $in->getEntityUniqueId();
$this->eventType = $in->getUnsignedVarInt();
switch($this->eventType){
case self::TYPE_REGISTER_PLAYER:
case self::TYPE_UNREGISTER_PLAYER:
$this->playerEid = $in->getEntityUniqueId();
break;
/** @noinspection PhpMissingBreakStatementInspection */
case self::TYPE_SHOW:
$this->title = $in->getString();
$this->healthPercent = $in->getLFloat();
/** @noinspection PhpMissingBreakStatementInspection */
case self::TYPE_UNKNOWN_6:
$this->unknownShort = $in->getLShort();
case self::TYPE_TEXTURE:
$this->color = $in->getUnsignedVarInt();
$this->overlay = $in->getUnsignedVarInt();
break;
case self::TYPE_HEALTH_PERCENT:
$this->healthPercent = $in->getLFloat();
break;
case self::TYPE_TITLE:
$this->title = $in->getString();
break;
default:
break;
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->bossEid);
$out->putUnsignedVarInt($this->eventType);
switch($this->eventType){
case self::TYPE_REGISTER_PLAYER:
case self::TYPE_UNREGISTER_PLAYER:
$out->putEntityUniqueId($this->playerEid);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case self::TYPE_SHOW:
$out->putString($this->title);
$out->putLFloat($this->healthPercent);
/** @noinspection PhpMissingBreakStatementInspection */
case self::TYPE_UNKNOWN_6:
$out->putLShort($this->unknownShort);
case self::TYPE_TEXTURE:
$out->putUnsignedVarInt($this->color);
$out->putUnsignedVarInt($this->overlay);
break;
case self::TYPE_HEALTH_PERCENT:
$out->putLFloat($this->healthPercent);
break;
case self::TYPE_TITLE:
$out->putString($this->title);
break;
default:
break;
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleBossEvent($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CameraPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CAMERA_PACKET;
/** @var int */
public $cameraUniqueId;
/** @var int */
public $playerUniqueId;
protected function decodePayload(PacketSerializer $in) : void{
$this->cameraUniqueId = $in->getEntityUniqueId();
$this->playerUniqueId = $in->getEntityUniqueId();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->cameraUniqueId);
$out->putEntityUniqueId($this->playerUniqueId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCamera($this);
}
}

View File

@ -1,82 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CameraShakePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CAMERA_SHAKE_PACKET;
public const TYPE_POSITIONAL = 0;
public const TYPE_ROTATIONAL = 1;
public const ACTION_ADD = 0;
public const ACTION_STOP = 1;
/** @var float */
private $intensity;
/** @var float */
private $duration;
/** @var int */
private $shakeType;
/** @var int */
private $shakeAction;
public static function create(float $intensity, float $duration, int $shakeType, int $shakeAction) : self{
$result = new self;
$result->intensity = $intensity;
$result->duration = $duration;
$result->shakeType = $shakeType;
$result->shakeAction = $shakeAction;
return $result;
}
public function getIntensity() : float{ return $this->intensity; }
public function getDuration() : float{ return $this->duration; }
public function getShakeType() : int{ return $this->shakeType; }
public function getShakeAction() : int{ return $this->shakeAction; }
protected function decodePayload(PacketSerializer $in) : void{
$this->intensity = $in->getLFloat();
$this->duration = $in->getLFloat();
$this->shakeType = $in->getByte();
$this->shakeAction = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLFloat($this->intensity);
$out->putLFloat($this->duration);
$out->putByte($this->shakeType);
$out->putByte($this->shakeAction);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCameraShake($this);
}
}

View File

@ -1,56 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET;
/** @var int */
public $dimension;
/** @var Vector3 */
public $position;
/** @var bool */
public $respawn = false;
protected function decodePayload(PacketSerializer $in) : void{
$this->dimension = $in->getVarInt();
$this->position = $in->getVector3();
$this->respawn = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->dimension);
$out->putVector3($this->position);
$out->putBool($this->respawn);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleChangeDimension($this);
}
}

View File

@ -1,53 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET;
/** @var int */
public $radius;
public static function create(int $radius) : self{
$result = new self;
$result->radius = $radius;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->radius = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->radius);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleChunkRadiusUpdated($this);
}
}

View File

@ -1,93 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use function count;
class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_BLOB_STATUS_PACKET;
/** @var int[] xxHash64 subchunk data hashes */
private $hitHashes = [];
/** @var int[] xxHash64 subchunk data hashes */
private $missHashes = [];
/**
* @param int[] $hitHashes
* @param int[] $missHashes
*/
public static function create(array $hitHashes, array $missHashes) : self{
//type checks
(static function(int ...$hashes) : void{})(...$hitHashes);
(static function(int ...$hashes) : void{})(...$missHashes);
$result = new self;
$result->hitHashes = $hitHashes;
$result->missHashes = $missHashes;
return $result;
}
/**
* @return int[]
*/
public function getHitHashes() : array{
return $this->hitHashes;
}
/**
* @return int[]
*/
public function getMissHashes() : array{
return $this->missHashes;
}
protected function decodePayload(PacketSerializer $in) : void{
$missCount = $in->getUnsignedVarInt();
$hitCount = $in->getUnsignedVarInt();
for($i = 0; $i < $missCount; ++$i){
$this->missHashes[] = $in->getLLong();
}
for($i = 0; $i < $hitCount; ++$i){
$this->hitHashes[] = $in->getLLong();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->missHashes));
$out->putUnsignedVarInt(count($this->hitHashes));
foreach($this->missHashes as $hash){
$out->putLLong($hash);
}
foreach($this->hitHashes as $hash){
$out->putLLong($hash);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientCacheBlobStatus($this);
}
}

View File

@ -1,76 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\ChunkCacheBlob;
use function count;
class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_MISS_RESPONSE_PACKET;
/** @var ChunkCacheBlob[] */
private $blobs = [];
/**
* @param ChunkCacheBlob[] $blobs
*/
public static function create(array $blobs) : self{
//type check
(static function(ChunkCacheBlob ...$blobs) : void{})(...$blobs);
$result = new self;
$result->blobs = $blobs;
return $result;
}
/**
* @return ChunkCacheBlob[]
*/
public function getBlobs() : array{
return $this->blobs;
}
protected function decodePayload(PacketSerializer $in) : void{
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$hash = $in->getLLong();
$payload = $in->getString();
$this->blobs[] = new ChunkCacheBlob($hash, $payload);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->blobs));
foreach($this->blobs as $blob){
$out->putLLong($blob->getHash());
$out->putString($blob->getPayload());
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientCacheMissResponse($this);
}
}

View File

@ -1,57 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_STATUS_PACKET;
/** @var bool */
private $enabled;
public static function create(bool $enabled) : self{
$result = new self;
$result->enabled = $enabled;
return $result;
}
public function isEnabled() : bool{
return $this->enabled;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->enabled = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBool($this->enabled);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientCacheStatus($this);
}
}

View File

@ -1,48 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ClientToServerHandshakePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET;
public function canBeSentBeforeLogin() : bool{
return true;
}
protected function decodePayload(PacketSerializer $in) : void{
//No payload
}
protected function encodePayload(PacketSerializer $out) : void{
//No payload
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientToServerHandshake($this);
}
}

View File

@ -1,137 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ClientboundDebugRendererPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DEBUG_RENDERER_PACKET;
public const TYPE_CLEAR = 1;
public const TYPE_ADD_CUBE = 2;
/** @var int */
private $type;
//TODO: if more types are added, we'll probably want to make a separate data type and interfaces
/** @var string */
private $text;
/** @var Vector3 */
private $position;
/** @var float */
private $red;
/** @var float */
private $green;
/** @var float */
private $blue;
/** @var float */
private $alpha;
/** @var int */
private $durationMillis;
private static function base(int $type) : self{
$result = new self;
$result->type = $type;
return $result;
}
public static function clear() : self{ return self::base(self::TYPE_CLEAR); }
public static function addCube(string $text, Vector3 $position, float $red, float $green, float $blue, float $alpha, int $durationMillis) : self{
$result = self::base(self::TYPE_ADD_CUBE);
$result->text = $text;
$result->position = $position;
$result->red = $red;
$result->green = $green;
$result->blue = $blue;
$result->alpha = $alpha;
$result->durationMillis = $durationMillis;
return $result;
}
public function getType() : int{ return $this->type; }
public function getText() : string{ return $this->text; }
public function getPosition() : Vector3{ return $this->position; }
public function getRed() : float{ return $this->red; }
public function getGreen() : float{ return $this->green; }
public function getBlue() : float{ return $this->blue; }
public function getAlpha() : float{ return $this->alpha; }
public function getDurationMillis() : int{ return $this->durationMillis; }
protected function decodePayload(PacketSerializer $in) : void{
$this->type = $in->getLInt();
switch($this->type){
case self::TYPE_CLEAR:
//NOOP
break;
case self::TYPE_ADD_CUBE:
$this->text = $in->getString();
$this->position = $in->getVector3();
$this->red = $in->getLFloat();
$this->green = $in->getLFloat();
$this->blue = $in->getLFloat();
$this->alpha = $in->getLFloat();
$this->durationMillis = $in->getLLong();
break;
default:
throw new \UnexpectedValueException("Unknown type " . $this->type);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLInt($this->type);
switch($this->type){
case self::TYPE_CLEAR:
//NOOP
break;
case self::TYPE_ADD_CUBE:
$out->putString($this->text);
$out->putVector3($this->position);
$out->putLFloat($this->red);
$out->putLFloat($this->green);
$out->putLFloat($this->blue);
$out->putLFloat($this->alpha);
$out->putLLong($this->durationMillis);
break;
default:
throw new \InvalidArgumentException("Unknown type " . $this->type);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientboundDebugRenderer($this);
}
}

View File

@ -1,208 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\color\Color;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\DimensionIds;
use pocketmine\network\mcpe\protocol\types\MapDecoration;
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
use function count;
#ifndef COMPILE
use pocketmine\utils\Binary;
#endif
class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_MAP_ITEM_DATA_PACKET;
public const BITFLAG_TEXTURE_UPDATE = 0x02;
public const BITFLAG_DECORATION_UPDATE = 0x04;
/** @var int */
public $mapId;
/** @var int */
public $type;
/** @var int */
public $dimensionId = DimensionIds::OVERWORLD;
/** @var bool */
public $isLocked = false;
/** @var int[] */
public $eids = [];
/** @var int */
public $scale;
/** @var MapTrackedObject[] */
public $trackedEntities = [];
/** @var MapDecoration[] */
public $decorations = [];
/** @var int */
public $width;
/** @var int */
public $height;
/** @var int */
public $xOffset = 0;
/** @var int */
public $yOffset = 0;
/** @var Color[][] */
public $colors = [];
protected function decodePayload(PacketSerializer $in) : void{
$this->mapId = $in->getEntityUniqueId();
$this->type = $in->getUnsignedVarInt();
$this->dimensionId = $in->getByte();
$this->isLocked = $in->getBool();
if(($this->type & 0x08) !== 0){
$count = $in->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->eids[] = $in->getEntityUniqueId();
}
}
if(($this->type & (0x08 | self::BITFLAG_DECORATION_UPDATE | self::BITFLAG_TEXTURE_UPDATE)) !== 0){ //Decoration bitflag or colour bitflag
$this->scale = $in->getByte();
}
if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$object = new MapTrackedObject();
$object->type = $in->getLInt();
if($object->type === MapTrackedObject::TYPE_BLOCK){
$in->getBlockPosition($object->x, $object->y, $object->z);
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
$object->entityUniqueId = $in->getEntityUniqueId();
}else{
throw new PacketDecodeException("Unknown map object type $object->type");
}
$this->trackedEntities[] = $object;
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$icon = $in->getByte();
$rotation = $in->getByte();
$xOffset = $in->getByte();
$yOffset = $in->getByte();
$label = $in->getString();
$color = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt()));
$this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color);
}
}
if(($this->type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
$this->width = $in->getVarInt();
$this->height = $in->getVarInt();
$this->xOffset = $in->getVarInt();
$this->yOffset = $in->getVarInt();
$count = $in->getUnsignedVarInt();
if($count !== $this->width * $this->height){
throw new PacketDecodeException("Expected colour count of " . ($this->height * $this->width) . " (height $this->height * width $this->width), got $count");
}
for($y = 0; $y < $this->height; ++$y){
for($x = 0; $x < $this->width; ++$x){
$this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($in->getUnsignedVarInt()));
}
}
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->mapId);
$type = 0;
if(($eidsCount = count($this->eids)) > 0){
$type |= 0x08;
}
if(($decorationCount = count($this->decorations)) > 0){
$type |= self::BITFLAG_DECORATION_UPDATE;
}
if(count($this->colors) > 0){
$type |= self::BITFLAG_TEXTURE_UPDATE;
}
$out->putUnsignedVarInt($type);
$out->putByte($this->dimensionId);
$out->putBool($this->isLocked);
if(($type & 0x08) !== 0){ //TODO: find out what these are for
$out->putUnsignedVarInt($eidsCount);
foreach($this->eids as $eid){
$out->putEntityUniqueId($eid);
}
}
if(($type & (0x08 | self::BITFLAG_TEXTURE_UPDATE | self::BITFLAG_DECORATION_UPDATE)) !== 0){
$out->putByte($this->scale);
}
if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){
$out->putUnsignedVarInt(count($this->trackedEntities));
foreach($this->trackedEntities as $object){
$out->putLInt($object->type);
if($object->type === MapTrackedObject::TYPE_BLOCK){
$out->putBlockPosition($object->x, $object->y, $object->z);
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
$out->putEntityUniqueId($object->entityUniqueId);
}else{
throw new \InvalidArgumentException("Unknown map object type $object->type");
}
}
$out->putUnsignedVarInt($decorationCount);
foreach($this->decorations as $decoration){
$out->putByte($decoration->getIcon());
$out->putByte($decoration->getRotation());
$out->putByte($decoration->getXOffset());
$out->putByte($decoration->getYOffset());
$out->putString($decoration->getLabel());
$out->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
}
}
if(($type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
$out->putVarInt($this->width);
$out->putVarInt($this->height);
$out->putVarInt($this->xOffset);
$out->putVarInt($this->yOffset);
$out->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
for($y = 0; $y < $this->height; ++$y){
for($x = 0; $x < $this->width; ++$x){
//if mojang had any sense this would just be a regular LE int
$out->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA()));
}
}
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleClientboundMapItemData($this);
}
}

View File

@ -1,28 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
interface ClientboundPacket extends Packet{
}

View File

@ -1,66 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CodeBuilderPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CODE_BUILDER_PACKET;
/** @var string */
private $url;
/** @var bool */
private $openCodeBuilder;
public static function create(string $url, bool $openCodeBuilder) : self{
$result = new self;
$result->url = $url;
$result->openCodeBuilder = $openCodeBuilder;
return $result;
}
public function getUrl() : string{
return $this->url;
}
public function openCodeBuilder() : bool{
return $this->openCodeBuilder;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->url = $in->getString();
$this->openCodeBuilder = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->url);
$out->putBool($this->openCodeBuilder);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCodeBuilder($this);
}
}

View File

@ -1,111 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
/** @var bool */
public $isBlock;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $commandBlockMode;
/** @var bool */
public $isRedstoneMode;
/** @var bool */
public $isConditional;
/** @var int */
public $minecartEid;
/** @var string */
public $command;
/** @var string */
public $lastOutput;
/** @var string */
public $name;
/** @var bool */
public $shouldTrackOutput;
/** @var int */
public $tickDelay;
/** @var bool */
public $executeOnFirstTick;
protected function decodePayload(PacketSerializer $in) : void{
$this->isBlock = $in->getBool();
if($this->isBlock){
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->commandBlockMode = $in->getUnsignedVarInt();
$this->isRedstoneMode = $in->getBool();
$this->isConditional = $in->getBool();
}else{
//Minecart with command block
$this->minecartEid = $in->getEntityRuntimeId();
}
$this->command = $in->getString();
$this->lastOutput = $in->getString();
$this->name = $in->getString();
$this->shouldTrackOutput = $in->getBool();
$this->tickDelay = $in->getLInt();
$this->executeOnFirstTick = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBool($this->isBlock);
if($this->isBlock){
$out->putBlockPosition($this->x, $this->y, $this->z);
$out->putUnsignedVarInt($this->commandBlockMode);
$out->putBool($this->isRedstoneMode);
$out->putBool($this->isConditional);
}else{
$out->putEntityRuntimeId($this->minecartEid);
}
$out->putString($this->command);
$out->putString($this->lastOutput);
$out->putString($this->name);
$out->putBool($this->shouldTrackOutput);
$out->putLInt($this->tickDelay);
$out->putBool($this->executeOnFirstTick);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCommandBlockUpdate($this);
}
}

View File

@ -1,111 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
use pocketmine\network\mcpe\protocol\types\command\CommandOutputMessage;
use pocketmine\utils\BinaryDataException;
use function count;
class CommandOutputPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
public const TYPE_LAST = 1;
public const TYPE_SILENT = 2;
public const TYPE_ALL = 3;
public const TYPE_DATA_SET = 4;
/** @var CommandOriginData */
public $originData;
/** @var int */
public $outputType;
/** @var int */
public $successCount;
/** @var CommandOutputMessage[] */
public $messages = [];
/** @var string */
public $unknownString;
protected function decodePayload(PacketSerializer $in) : void{
$this->originData = $in->getCommandOriginData();
$this->outputType = $in->getByte();
$this->successCount = $in->getUnsignedVarInt();
for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){
$this->messages[] = $this->getCommandMessage($in);
}
if($this->outputType === self::TYPE_DATA_SET){
$this->unknownString = $in->getString();
}
}
/**
* @throws BinaryDataException
*/
protected function getCommandMessage(PacketSerializer $in) : CommandOutputMessage{
$message = new CommandOutputMessage();
$message->isInternal = $in->getBool();
$message->messageId = $in->getString();
for($i = 0, $size = $in->getUnsignedVarInt(); $i < $size; ++$i){
$message->parameters[] = $in->getString();
}
return $message;
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putCommandOriginData($this->originData);
$out->putByte($this->outputType);
$out->putUnsignedVarInt($this->successCount);
$out->putUnsignedVarInt(count($this->messages));
foreach($this->messages as $message){
$this->putCommandMessage($message, $out);
}
if($this->outputType === self::TYPE_DATA_SET){
$out->putString($this->unknownString);
}
}
protected function putCommandMessage(CommandOutputMessage $message, PacketSerializer $out) : void{
$out->putBool($message->isInternal);
$out->putString($message->messageId);
$out->putUnsignedVarInt(count($message->parameters));
foreach($message->parameters as $parameter){
$out->putString($parameter);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCommandOutput($this);
}
}

View File

@ -1,56 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\command\CommandOriginData;
class CommandRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET;
/** @var string */
public $command;
/** @var CommandOriginData */
public $originData;
/** @var bool */
public $isInternal;
protected function decodePayload(PacketSerializer $in) : void{
$this->command = $in->getString();
$this->originData = $in->getCommandOriginData();
$this->isInternal = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->command);
$out->putCommandOriginData($this->originData);
$out->putBool($this->isInternal);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCommandRequest($this);
}
}

View File

@ -1,68 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::COMPLETED_USING_ITEM_PACKET;
public const ACTION_UNKNOWN = -1;
public const ACTION_EQUIP_ARMOR = 0;
public const ACTION_EAT = 1;
public const ACTION_ATTACK = 2;
public const ACTION_CONSUME = 3;
public const ACTION_THROW = 4;
public const ACTION_SHOOT = 5;
public const ACTION_PLACE = 6;
public const ACTION_FILL_BOTTLE = 7;
public const ACTION_FILL_BUCKET = 8;
public const ACTION_POUR_BUCKET = 9;
public const ACTION_USE_TOOL = 10;
public const ACTION_INTERACT = 11;
public const ACTION_RETRIEVED = 12;
public const ACTION_DYED = 13;
public const ACTION_TRADED = 14;
/** @var int */
public $itemId;
/** @var int */
public $action;
public function decodePayload(PacketSerializer $in) : void{
$this->itemId = $in->getShort();
$this->action = $in->getLInt();
}
public function encodePayload(PacketSerializer $out) : void{
$out->putShort($this->itemId);
$out->putLInt($this->action);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCompletedUsingItem($this);
}
}

View File

@ -1,58 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ContainerClosePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;
/** @var int */
public $windowId;
/** @var bool */
public $server = false;
public static function create(int $windowId, bool $server) : self{
$result = new self;
$result->windowId = $windowId;
$result->server = $server;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getByte();
$this->server = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->windowId);
$out->putBool($this->server);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleContainerClose($this);
}
}

View File

@ -1,85 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ContainerOpenPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET;
/** @var int */
public $windowId;
/** @var int */
public $type;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $entityUniqueId = -1;
public static function blockInv(int $windowId, int $windowType, int $x, int $y, int $z) : self{
$result = new self;
$result->windowId = $windowId;
$result->type = $windowType;
[$result->x, $result->y, $result->z] = [$x, $y, $z];
return $result;
}
public static function blockInvVec3(int $windowId, int $windowType, Vector3 $vector3) : self{
return self::blockInv($windowId, $windowType, $vector3->getFloorX(), $vector3->getFloorY(), $vector3->getFloorZ());
}
public static function entityInv(int $windowId, int $windowType, int $entityUniqueId) : self{
$result = new self;
$result->windowId = $windowId;
$result->type = $windowType;
$result->entityUniqueId = $entityUniqueId;
$result->x = $result->y = $result->z = 0; //these have to be set even if they aren't used
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getByte();
$this->type = $in->getByte();
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->entityUniqueId = $in->getEntityUniqueId();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->windowId);
$out->putByte($this->type);
$out->putBlockPosition($this->x, $this->y, $this->z);
$out->putEntityUniqueId($this->entityUniqueId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleContainerOpen($this);
}
}

View File

@ -1,73 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET;
public const PROPERTY_FURNACE_SMELT_PROGRESS = 0;
public const PROPERTY_FURNACE_REMAINING_FUEL_TIME = 1;
public const PROPERTY_FURNACE_MAX_FUEL_TIME = 2;
public const PROPERTY_FURNACE_STORED_XP = 3;
public const PROPERTY_FURNACE_FUEL_AUX = 4;
public const PROPERTY_BREWING_STAND_BREW_TIME = 0;
public const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1;
public const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2;
/** @var int */
public $windowId;
/** @var int */
public $property;
/** @var int */
public $value;
public static function create(int $windowId, int $propertyId, int $value) : self{
$result = new self;
$result->property = $propertyId;
$result->value = $value;
$result->windowId = $windowId;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getByte();
$this->property = $in->getVarInt();
$this->value = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->windowId);
$out->putVarInt($this->property);
$out->putVarInt($this->value);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleContainerSetData($this);
}
}

View File

@ -1,77 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class CorrectPlayerMovePredictionPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CORRECT_PLAYER_MOVE_PREDICTION_PACKET;
/** @var Vector3 */
private $position;
/** @var Vector3 */
private $delta;
/** @var bool */
private $onGround;
/** @var int */
private $tick;
public static function create(Vector3 $position, Vector3 $delta, bool $onGround, int $tick) : self{
$result = new self;
$result->position = $position;
$result->delta = $delta;
$result->onGround = $onGround;
$result->tick = $tick;
return $result;
}
public function getPosition() : Vector3{ return $this->position; }
public function getDelta() : Vector3{ return $this->delta; }
public function isOnGround() : bool{ return $this->onGround; }
public function getTick() : int{ return $this->tick; }
protected function decodePayload(PacketSerializer $in) : void{
$this->position = $in->getVector3();
$this->delta = $in->getVector3();
$this->onGround = $in->getBool();
$this->tick = $in->getUnsignedVarLong();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVector3($this->position);
$out->putVector3($this->delta);
$out->putBool($this->onGround);
$out->putUnsignedVarLong($this->tick);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCorrectPlayerMovePrediction($this);
}
}

View File

@ -1,131 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\recipe\FurnaceRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\MultiRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\PotionContainerChangeRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\PotionTypeRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\RecipeWithTypeId;
use pocketmine\network\mcpe\protocol\types\recipe\ShapedRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\ShapelessRecipe;
use function count;
class CraftingDataPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CRAFTING_DATA_PACKET;
public const ENTRY_SHAPELESS = 0;
public const ENTRY_SHAPED = 1;
public const ENTRY_FURNACE = 2;
public const ENTRY_FURNACE_DATA = 3;
public const ENTRY_MULTI = 4;
public const ENTRY_SHULKER_BOX = 5;
public const ENTRY_SHAPELESS_CHEMISTRY = 6;
public const ENTRY_SHAPED_CHEMISTRY = 7;
/** @var RecipeWithTypeId[] */
public $entries = [];
/** @var PotionTypeRecipe[] */
public $potionTypeRecipes = [];
/** @var PotionContainerChangeRecipe[] */
public $potionContainerRecipes = [];
/** @var bool */
public $cleanRecipes = false;
protected function decodePayload(PacketSerializer $in) : void{
$recipeCount = $in->getUnsignedVarInt();
for($i = 0; $i < $recipeCount; ++$i){
$recipeType = $in->getVarInt();
switch($recipeType){
case self::ENTRY_SHAPELESS:
case self::ENTRY_SHULKER_BOX:
case self::ENTRY_SHAPELESS_CHEMISTRY:
$this->entries[] = ShapelessRecipe::decode($recipeType, $in);
break;
case self::ENTRY_SHAPED:
case self::ENTRY_SHAPED_CHEMISTRY:
$this->entries[] = ShapedRecipe::decode($recipeType, $in);
break;
case self::ENTRY_FURNACE:
case self::ENTRY_FURNACE_DATA:
$this->entries[] = FurnaceRecipe::decode($recipeType, $in);
break;
case self::ENTRY_MULTI:
$this->entries[] = MultiRecipe::decode($recipeType, $in);
break;
default:
throw new PacketDecodeException("Unhandled recipe type $recipeType!"); //do not continue attempting to decode
}
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$inputId = $in->getVarInt();
$inputMeta = $in->getVarInt();
$ingredientId = $in->getVarInt();
$ingredientMeta = $in->getVarInt();
$outputId = $in->getVarInt();
$outputMeta = $in->getVarInt();
$this->potionTypeRecipes[] = new PotionTypeRecipe($inputId, $inputMeta, $ingredientId, $ingredientMeta, $outputId, $outputMeta);
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$input = $in->getVarInt();
$ingredient = $in->getVarInt();
$output = $in->getVarInt();
$this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output);
}
$this->cleanRecipes = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $d){
$out->putVarInt($d->getTypeId());
$d->encode($out);
}
$out->putUnsignedVarInt(count($this->potionTypeRecipes));
foreach($this->potionTypeRecipes as $recipe){
$out->putVarInt($recipe->getInputItemId());
$out->putVarInt($recipe->getInputItemMeta());
$out->putVarInt($recipe->getIngredientItemId());
$out->putVarInt($recipe->getIngredientItemMeta());
$out->putVarInt($recipe->getOutputItemId());
$out->putVarInt($recipe->getOutputItemMeta());
}
$out->putUnsignedVarInt(count($this->potionContainerRecipes));
foreach($this->potionContainerRecipes as $recipe){
$out->putVarInt($recipe->getInputItemId());
$out->putVarInt($recipe->getIngredientItemId());
$out->putVarInt($recipe->getOutputItemId());
}
$out->putBool($this->cleanRecipes);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCraftingData($this);
}
}

View File

@ -1,82 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use Ramsey\Uuid\UuidInterface;
use function count;
class CraftingEventPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET;
/** @var int */
public $windowId;
/** @var int */
public $type;
/** @var UuidInterface */
public $id;
/** @var ItemStackWrapper[] */
public $input = [];
/** @var ItemStackWrapper[] */
public $output = [];
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getByte();
$this->type = $in->getVarInt();
$this->id = $in->getUUID();
$size = $in->getUnsignedVarInt();
for($i = 0; $i < $size and $i < 128; ++$i){
$this->input[] = ItemStackWrapper::read($in);
}
$size = $in->getUnsignedVarInt();
for($i = 0; $i < $size and $i < 128; ++$i){
$this->output[] = ItemStackWrapper::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->windowId);
$out->putVarInt($this->type);
$out->putUUID($this->id);
$out->putUnsignedVarInt(count($this->input));
foreach($this->input as $item){
$item->write($out);
}
$out->putUnsignedVarInt(count($this->output));
foreach($this->output as $item){
$item->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCraftingEvent($this);
}
}

View File

@ -1,67 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\CreativeContentEntry;
use function count;
class CreativeContentPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CREATIVE_CONTENT_PACKET;
/** @var CreativeContentEntry[] */
private $entries;
/**
* @param CreativeContentEntry[] $entries
*/
public static function create(array $entries) : self{
$result = new self;
$result->entries = $entries;
return $result;
}
/** @return CreativeContentEntry[] */
public function getEntries() : array{ return $this->entries; }
protected function decodePayload(PacketSerializer $in) : void{
$this->entries = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->entries[] = CreativeContentEntry::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$entry->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCreativeContent($this);
}
}

View File

@ -1,129 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\utils\BinaryDataException;
use function get_class;
abstract class DataPacket implements Packet{
public const NETWORK_ID = 0;
public const PID_MASK = 0x3ff; //10 bits
private const SUBCLIENT_ID_MASK = 0x03; //2 bits
private const SENDER_SUBCLIENT_ID_SHIFT = 10;
private const RECIPIENT_SUBCLIENT_ID_SHIFT = 12;
/** @var int */
public $senderSubId = 0;
/** @var int */
public $recipientSubId = 0;
public function pid() : int{
return $this::NETWORK_ID;
}
public function getName() : string{
return (new \ReflectionClass($this))->getShortName();
}
public function canBeSentBeforeLogin() : bool{
return false;
}
/**
* @throws PacketDecodeException
*/
final public function decode(PacketSerializer $in) : void{
try{
$this->decodeHeader($in);
$this->decodePayload($in);
}catch(BinaryDataException | PacketDecodeException $e){
throw PacketDecodeException::wrap($e, $this->getName());
}
}
/**
* @throws BinaryDataException
* @throws \UnexpectedValueException
*/
protected function decodeHeader(PacketSerializer $in) : void{
$header = $in->getUnsignedVarInt();
$pid = $header & self::PID_MASK;
if($pid !== static::NETWORK_ID){
//TODO: this means a logical error in the code, but how to prevent it from happening?
throw new \UnexpectedValueException("Expected " . static::NETWORK_ID . " for packet ID, got $pid");
}
$this->senderSubId = ($header >> self::SENDER_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK;
$this->recipientSubId = ($header >> self::RECIPIENT_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK;
}
/**
* Decodes the packet body, without the packet ID or other generic header fields.
*
* @throws PacketDecodeException
* @throws BinaryDataException
*/
abstract protected function decodePayload(PacketSerializer $in) : void;
final public function encode(PacketSerializer $out) : void{
$this->encodeHeader($out);
$this->encodePayload($out);
}
protected function encodeHeader(PacketSerializer $out) : void{
$out->putUnsignedVarInt(
static::NETWORK_ID |
($this->senderSubId << self::SENDER_SUBCLIENT_ID_SHIFT) |
($this->recipientSubId << self::RECIPIENT_SUBCLIENT_ID_SHIFT)
);
}
/**
* Encodes the packet body, without the packet ID or other generic header fields.
*/
abstract protected function encodePayload(PacketSerializer $out) : void;
/**
* @param string $name
*
* @return mixed
*/
public function __get($name){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
}
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value) : void{
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class DebugInfoPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::DEBUG_INFO_PACKET;
/** @var int */
private $entityUniqueId;
/** @var string */
private $data;
public static function create(int $entityUniqueId, string $data) : self{
$result = new self;
$result->entityUniqueId = $entityUniqueId;
$result->data = $data;
return $result;
}
/**
* TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi)
*/
public function getEntityUniqueIdField() : int{ return $this->entityUniqueId; }
public function getData() : string{ return $this->data; }
protected function decodePayload(PacketSerializer $in) : void{
$this->entityUniqueId = $in->getEntityUniqueId();
$this->data = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->entityUniqueId);
$out->putString($this->data);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleDebugInfo($this);
}
}

View File

@ -1,72 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class DisconnectPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET;
/** @var bool */
public $hideDisconnectionScreen = false;
/** @var string */
public $message = "";
public static function silent() : self{
$result = new self;
$result->hideDisconnectionScreen = true;
return $result;
}
public static function message(string $message) : self{
$result = new self;
$result->hideDisconnectionScreen = false;
$result->message = $message;
return $result;
}
public function canBeSentBeforeLogin() : bool{
return true;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->hideDisconnectionScreen = $in->getBool();
if(!$this->hideDisconnectionScreen){
$this->message = $in->getString();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBool($this->hideDisconnectionScreen);
if(!$this->hideDisconnectionScreen){
$out->putString($this->message);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleDisconnect($this);
}
}

View File

@ -1,100 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class EducationSettingsPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET;
/** @var string */
private $codeBuilderDefaultUri;
/** @var string */
private $codeBuilderTitle;
/** @var bool */
private $canResizeCodeBuilder;
/** @var string|null */
private $codeBuilderOverrideUri;
/** @var bool */
private $hasQuiz;
public static function create(string $codeBuilderDefaultUri, string $codeBuilderTitle, bool $canResizeCodeBuilder, ?string $codeBuilderOverrideUri, bool $hasQuiz) : self{
$result = new self;
$result->codeBuilderDefaultUri = $codeBuilderDefaultUri;
$result->codeBuilderTitle = $codeBuilderTitle;
$result->canResizeCodeBuilder = $canResizeCodeBuilder;
$result->codeBuilderOverrideUri = $codeBuilderOverrideUri;
$result->hasQuiz = $hasQuiz;
return $result;
}
public function getCodeBuilderDefaultUri() : string{
return $this->codeBuilderDefaultUri;
}
public function getCodeBuilderTitle() : string{
return $this->codeBuilderTitle;
}
public function canResizeCodeBuilder() : bool{
return $this->canResizeCodeBuilder;
}
public function getCodeBuilderOverrideUri() : ?string{
return $this->codeBuilderOverrideUri;
}
public function getHasQuiz() : bool{
return $this->hasQuiz;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->codeBuilderDefaultUri = $in->getString();
$this->codeBuilderTitle = $in->getString();
$this->canResizeCodeBuilder = $in->getBool();
if($in->getBool()){
$this->codeBuilderOverrideUri = $in->getString();
}else{
$this->codeBuilderOverrideUri = null;
}
$this->hasQuiz = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->codeBuilderDefaultUri);
$out->putString($this->codeBuilderTitle);
$out->putBool($this->canResizeCodeBuilder);
$out->putBool($this->codeBuilderOverrideUri !== null);
if($this->codeBuilderOverrideUri !== null){
$out->putString($this->codeBuilderOverrideUri);
}
$out->putBool($this->hasQuiz);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleEducationSettings($this);
}
}

View File

@ -1,74 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use Ramsey\Uuid\UuidInterface;
use function count;
class EmoteListPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::EMOTE_LIST_PACKET;
/** @var int */
private $playerEntityRuntimeId;
/** @var UuidInterface[] */
private $emoteIds;
/**
* @param UuidInterface[] $emoteIds
*/
public static function create(int $playerEntityRuntimeId, array $emoteIds) : self{
$result = new self;
$result->playerEntityRuntimeId = $playerEntityRuntimeId;
$result->emoteIds = $emoteIds;
return $result;
}
public function getPlayerEntityRuntimeId() : int{ return $this->playerEntityRuntimeId; }
/** @return UuidInterface[] */
public function getEmoteIds() : array{ return $this->emoteIds; }
protected function decodePayload(PacketSerializer $in) : void{
$this->playerEntityRuntimeId = $in->getEntityRuntimeId();
$this->emoteIds = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->emoteIds[] = $in->getUUID();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->playerEntityRuntimeId);
$out->putUnsignedVarInt(count($this->emoteIds));
foreach($this->emoteIds as $emoteId){
$out->putUUID($emoteId);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleEmoteList($this);
}
}

View File

@ -1,80 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET;
public const FLAG_SERVER = 1 << 0;
/** @var int */
private $entityRuntimeId;
/** @var string */
private $emoteId;
/** @var int */
private $flags;
public static function create(int $entityRuntimeId, string $emoteId, int $flags) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->emoteId = $emoteId;
$result->flags = $flags;
return $result;
}
/**
* TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi)
*/
public function getEntityRuntimeIdField() : int{
return $this->entityRuntimeId;
}
public function getEmoteId() : string{
return $this->emoteId;
}
public function getFlags() : int{
return $this->flags;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->emoteId = $in->getString();
$this->flags = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putString($this->emoteId);
$out->putByte($this->flags);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleEmote($this);
}
}

View File

@ -1,85 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class EventPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::EVENT_PACKET;
public const TYPE_ACHIEVEMENT_AWARDED = 0;
public const TYPE_ENTITY_INTERACT = 1;
public const TYPE_PORTAL_BUILT = 2;
public const TYPE_PORTAL_USED = 3;
public const TYPE_MOB_KILLED = 4;
public const TYPE_CAULDRON_USED = 5;
public const TYPE_PLAYER_DEATH = 6;
public const TYPE_BOSS_KILLED = 7;
public const TYPE_AGENT_COMMAND = 8;
public const TYPE_AGENT_CREATED = 9;
public const TYPE_PATTERN_REMOVED = 10; //???
public const TYPE_COMMANED_EXECUTED = 11;
public const TYPE_FISH_BUCKETED = 12;
public const TYPE_MOB_BORN = 13;
public const TYPE_PET_DIED = 14;
public const TYPE_CAULDRON_BLOCK_USED = 15;
public const TYPE_COMPOSTER_BLOCK_USED = 16;
public const TYPE_BELL_BLOCK_USED = 17;
public const TYPE_ACTOR_DEFINITION = 18;
public const TYPE_RAID_UPDATE = 19;
public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat
public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21;
public const TYPE_HONEY_HARVESTED = 22;
public const TYPE_TARGET_BLOCK_HIT = 23;
public const TYPE_PIGLIN_BARTER = 24;
/** @var int */
public $playerRuntimeId;
/** @var int */
public $eventData;
/** @var int */
public $type;
protected function decodePayload(PacketSerializer $in) : void{
$this->playerRuntimeId = $in->getEntityRuntimeId();
$this->eventData = $in->getVarInt();
$this->type = $in->getByte();
//TODO: nice confusing mess
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->playerRuntimeId);
$out->putVarInt($this->eventData);
$out->putByte($this->type);
//TODO: also nice confusing mess
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleEvent($this);
}
}

View File

@ -1,62 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class FilterTextPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::FILTER_TEXT_PACKET;
/** @var string */
private $text;
/** @var bool */
private $fromServer;
public static function create(string $text, bool $server) : self{
$result = new self;
$result->text = $text;
$result->fromServer = $server;
return $result;
}
public function getText() : string{ return $this->text; }
public function isFromServer() : bool{ return $this->fromServer; }
protected function decodePayload(PacketSerializer $in) : void{
$this->text = $in->getString();
$this->fromServer = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->text);
$out->putBool($this->fromServer);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleFilterText($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\GameRule;
class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET;
/**
* @var GameRule[]
* @phpstan-var array<string, GameRule>
*/
public $gameRules = [];
protected function decodePayload(PacketSerializer $in) : void{
$this->gameRules = $in->getGameRules();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putGameRules($this->gameRules);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleGameRulesChanged($this);
}
}

View File

@ -1,55 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET;
/** @var string */
public $itemDescription;
/** @var string */
public $itemEffects;
/** @var int */
public $hotbarSlot;
protected function decodePayload(PacketSerializer $in) : void{
$this->itemDescription = $in->getString();
$this->itemEffects = $in->getString();
$this->hotbarSlot = $in->getLInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->itemDescription);
$out->putString($this->itemEffects);
$out->putLInt($this->hotbarSlot);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleGuiDataPickItem($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class HurtArmorPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
/** @var int */
public $cause;
/** @var int */
public $health;
protected function decodePayload(PacketSerializer $in) : void{
$this->cause = $in->getVarInt();
$this->health = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->cause);
$out->putVarInt($this->health);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleHurtArmor($this);
}
}

View File

@ -1,76 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class InteractPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::INTERACT_PACKET;
public const ACTION_LEAVE_VEHICLE = 3;
public const ACTION_MOUSEOVER = 4;
public const ACTION_OPEN_NPC = 5;
public const ACTION_OPEN_INVENTORY = 6;
/** @var int */
public $action;
/** @var int */
public $target;
/** @var float */
public $x;
/** @var float */
public $y;
/** @var float */
public $z;
protected function decodePayload(PacketSerializer $in) : void{
$this->action = $in->getByte();
$this->target = $in->getEntityRuntimeId();
if($this->action === self::ACTION_MOUSEOVER){
//TODO: should this be a vector3?
$this->x = $in->getLFloat();
$this->y = $in->getLFloat();
$this->z = $in->getLFloat();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->action);
$out->putEntityRuntimeId($this->target);
if($this->action === self::ACTION_MOUSEOVER){
$out->putLFloat($this->x);
$out->putLFloat($this->y);
$out->putLFloat($this->z);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleInteract($this);
}
}

View File

@ -1,71 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use function count;
class InventoryContentPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET;
/** @var int */
public $windowId;
/** @var ItemStackWrapper[] */
public $items = [];
/**
* @param ItemStackWrapper[] $items
*
* @return InventoryContentPacket
*/
public static function create(int $windowId, array $items) : self{
$result = new self;
$result->windowId = $windowId;
$result->items = $items;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getUnsignedVarInt();
$count = $in->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->items[] = ItemStackWrapper::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->windowId);
$out->putUnsignedVarInt(count($this->items));
foreach($this->items as $item){
$item->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleInventoryContent($this);
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
class InventorySlotPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;
/** @var int */
public $windowId;
/** @var int */
public $inventorySlot;
/** @var ItemStackWrapper */
public $item;
public static function create(int $windowId, int $slot, ItemStackWrapper $item) : self{
$result = new self;
$result->inventorySlot = $slot;
$result->item = $item;
$result->windowId = $windowId;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getUnsignedVarInt();
$this->inventorySlot = $in->getUnsignedVarInt();
$this->item = ItemStackWrapper::read($in);
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->windowId);
$out->putUnsignedVarInt($this->inventorySlot);
$this->item->write($out);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleInventorySlot($this);
}
}

View File

@ -1,108 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\InventoryTransactionChangedSlotsHack;
use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\NormalTransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\ReleaseItemTransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\TransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData;
use function count;
/**
* This packet effectively crams multiple packets into one.
*/
class InventoryTransactionPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::INVENTORY_TRANSACTION_PACKET;
public const TYPE_NORMAL = 0;
public const TYPE_MISMATCH = 1;
public const TYPE_USE_ITEM = 2;
public const TYPE_USE_ITEM_ON_ENTITY = 3;
public const TYPE_RELEASE_ITEM = 4;
/** @var int */
public $requestId;
/** @var InventoryTransactionChangedSlotsHack[] */
public $requestChangedSlots;
/** @var TransactionData */
public $trData;
protected function decodePayload(PacketSerializer $in) : void{
$this->requestId = $in->readGenericTypeNetworkId();
$this->requestChangedSlots = [];
if($this->requestId !== 0){
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($in);
}
}
$transactionType = $in->getUnsignedVarInt();
switch($transactionType){
case self::TYPE_NORMAL:
$this->trData = new NormalTransactionData();
break;
case self::TYPE_MISMATCH:
$this->trData = new MismatchTransactionData();
break;
case self::TYPE_USE_ITEM:
$this->trData = new UseItemTransactionData();
break;
case self::TYPE_USE_ITEM_ON_ENTITY:
$this->trData = new UseItemOnEntityTransactionData();
break;
case self::TYPE_RELEASE_ITEM:
$this->trData = new ReleaseItemTransactionData();
break;
default:
throw new PacketDecodeException("Unknown transaction type $transactionType");
}
$this->trData->decode($in);
}
protected function encodePayload(PacketSerializer $out) : void{
$out->writeGenericTypeNetworkId($this->requestId);
if($this->requestId !== 0){
$out->putUnsignedVarInt(count($this->requestChangedSlots));
foreach($this->requestChangedSlots as $changedSlots){
$changedSlots->write($out);
}
}
$out->putUnsignedVarInt($this->trData->getTypeId());
$this->trData->encode($out);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleInventoryTransaction($this);
}
}

View File

@ -1,79 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\nbt\TreeRoot;
use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\ItemComponentPacketEntry;
use function count;
class ItemComponentPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ITEM_COMPONENT_PACKET;
/**
* @var ItemComponentPacketEntry[]
* @phpstan-var list<ItemComponentPacketEntry>
*/
private $entries;
/**
* @param ItemComponentPacketEntry[] $entries
* @phpstan-param list<ItemComponentPacketEntry> $entries
*/
public static function create(array $entries) : self{
$result = new self;
$result->entries = $entries;
return $result;
}
/**
* @return ItemComponentPacketEntry[]
* @phpstan-return list<ItemComponentPacketEntry>
*/
public function getEntries() : array{ return $this->entries; }
protected function decodePayload(PacketSerializer $in) : void{
$this->entries = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$name = $in->getString();
$nbt = $in->getNbtCompoundRoot();
$this->entries[] = new ItemComponentPacketEntry($name, $nbt);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$out->putString($entry->getName());
$out->put((new NetworkNbtSerializer())->write(new TreeRoot($entry->getComponentNbt())));
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleItemComponent($this);
}
}

View File

@ -1,52 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
protected function decodePayload(PacketSerializer $in) : void{
$in->getBlockPosition($this->x, $this->y, $this->z);
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putBlockPosition($this->x, $this->y, $this->z);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleItemFrameDropItem($this);
}
}

View File

@ -1,67 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\ItemStackRequest;
use function count;
class ItemStackRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::ITEM_STACK_REQUEST_PACKET;
/** @var ItemStackRequest[] */
private $requests;
/**
* @param ItemStackRequest[] $requests
*/
public static function create(array $requests) : self{
$result = new self;
$result->requests = $requests;
return $result;
}
/** @return ItemStackRequest[] */
public function getRequests() : array{ return $this->requests; }
protected function decodePayload(PacketSerializer $in) : void{
$this->requests = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->requests[] = ItemStackRequest::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->requests));
foreach($this->requests as $request){
$request->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleItemStackRequest($this);
}
}

View File

@ -1,67 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponse;
use function count;
class ItemStackResponsePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ITEM_STACK_RESPONSE_PACKET;
/** @var ItemStackResponse[] */
private $responses;
/**
* @param ItemStackResponse[] $responses
*/
public static function create(array $responses) : self{
$result = new self;
$result->responses = $responses;
return $result;
}
/** @return ItemStackResponse[] */
public function getResponses() : array{ return $this->responses; }
protected function decodePayload(PacketSerializer $in) : void{
$this->responses = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->responses[] = ItemStackResponse::read($in);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->responses));
foreach($this->responses as $response){
$response->write($out);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleItemStackResponse($this);
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class LabTablePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET;
public const TYPE_START_COMBINE = 0;
public const TYPE_START_REACTION = 1;
public const TYPE_RESET = 2;
/** @var int */
public $type;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $reactionType;
protected function decodePayload(PacketSerializer $in) : void{
$this->type = $in->getByte();
$in->getSignedBlockPosition($this->x, $this->y, $this->z);
$this->reactionType = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->type);
$out->putSignedBlockPosition($this->x, $this->y, $this->z);
$out->putByte($this->reactionType);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLabTable($this);
}
}

View File

@ -1,63 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::LECTERN_UPDATE_PACKET;
/** @var int */
public $page;
/** @var int */
public $totalPages;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var bool */
public $dropBook;
protected function decodePayload(PacketSerializer $in) : void{
$this->page = $in->getByte();
$this->totalPages = $in->getByte();
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->dropBook = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->page);
$out->putByte($this->totalPages);
$out->putBlockPosition($this->x, $this->y, $this->z);
$out->putBool($this->dropBook);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLecternUpdate($this);
}
}

View File

@ -1,133 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use function count;
class LevelChunkPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_CHUNK_PACKET;
/** @var int */
private $chunkX;
/** @var int */
private $chunkZ;
/** @var int */
private $subChunkCount;
/** @var bool */
private $cacheEnabled;
/** @var int[] */
private $usedBlobHashes = [];
/** @var string */
private $extraPayload;
public static function withoutCache(int $chunkX, int $chunkZ, int $subChunkCount, string $payload) : self{
$result = new self;
$result->chunkX = $chunkX;
$result->chunkZ = $chunkZ;
$result->subChunkCount = $subChunkCount;
$result->extraPayload = $payload;
$result->cacheEnabled = false;
return $result;
}
/**
* @param int[] $usedBlobHashes
*/
public static function withCache(int $chunkX, int $chunkZ, int $subChunkCount, array $usedBlobHashes, string $extraPayload) : self{
(static function(int ...$hashes) : void{})(...$usedBlobHashes);
$result = new self;
$result->chunkX = $chunkX;
$result->chunkZ = $chunkZ;
$result->subChunkCount = $subChunkCount;
$result->extraPayload = $extraPayload;
$result->cacheEnabled = true;
$result->usedBlobHashes = $usedBlobHashes;
return $result;
}
public function getChunkX() : int{
return $this->chunkX;
}
public function getChunkZ() : int{
return $this->chunkZ;
}
public function getSubChunkCount() : int{
return $this->subChunkCount;
}
public function isCacheEnabled() : bool{
return $this->cacheEnabled;
}
/**
* @return int[]
*/
public function getUsedBlobHashes() : array{
return $this->usedBlobHashes;
}
public function getExtraPayload() : string{
return $this->extraPayload;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->chunkX = $in->getVarInt();
$this->chunkZ = $in->getVarInt();
$this->subChunkCount = $in->getUnsignedVarInt();
$this->cacheEnabled = $in->getBool();
if($this->cacheEnabled){
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$this->usedBlobHashes[] = $in->getLLong();
}
}
$this->extraPayload = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->chunkX);
$out->putVarInt($this->chunkZ);
$out->putUnsignedVarInt($this->subChunkCount);
$out->putBool($this->cacheEnabled);
if($this->cacheEnabled){
$out->putUnsignedVarInt(count($this->usedBlobHashes));
foreach($this->usedBlobHashes as $hash){
$out->putLLong($hash);
}
}
$out->putString($this->extraPayload);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelChunk($this);
}
}

View File

@ -1,74 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_GENERIC_PACKET;
/** @var int */
private $eventId;
/**
* @var CacheableNbt
* @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
*/
private $eventData;
public static function create(int $eventId, CompoundTag $data) : self{
$result = new self;
$result->eventId = $eventId;
$result->eventData = new CacheableNbt($data);
return $result;
}
public function getEventId() : int{
return $this->eventId;
}
/**
* @phpstan-return CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
*/
public function getEventData() : CacheableNbt{
return $this->eventData;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->eventId = $in->getVarInt();
$this->eventData = new CacheableNbt($in->getNbtCompoundRoot());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->eventId);
$out->put($this->eventData->getEncodedNbt());
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelEventGeneric($this);
}
}

View File

@ -1,151 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class LevelEventPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_PACKET;
public const EVENT_SOUND_CLICK = 1000;
public const EVENT_SOUND_CLICK_FAIL = 1001;
public const EVENT_SOUND_SHOOT = 1002;
public const EVENT_SOUND_DOOR = 1003;
public const EVENT_SOUND_FIZZ = 1004;
public const EVENT_SOUND_IGNITE = 1005;
public const EVENT_SOUND_GHAST = 1007;
public const EVENT_SOUND_GHAST_SHOOT = 1008;
public const EVENT_SOUND_BLAZE_SHOOT = 1009;
public const EVENT_SOUND_DOOR_BUMP = 1010;
public const EVENT_SOUND_DOOR_CRASH = 1012;
public const EVENT_SOUND_ENDERMAN_TELEPORT = 1018;
public const EVENT_SOUND_ANVIL_BREAK = 1020;
public const EVENT_SOUND_ANVIL_USE = 1021;
public const EVENT_SOUND_ANVIL_FALL = 1022;
public const EVENT_SOUND_POP = 1030;
public const EVENT_SOUND_PORTAL = 1032;
public const EVENT_SOUND_ITEMFRAME_ADD_ITEM = 1040;
public const EVENT_SOUND_ITEMFRAME_REMOVE = 1041;
public const EVENT_SOUND_ITEMFRAME_PLACE = 1042;
public const EVENT_SOUND_ITEMFRAME_REMOVE_ITEM = 1043;
public const EVENT_SOUND_ITEMFRAME_ROTATE_ITEM = 1044;
public const EVENT_SOUND_CAMERA = 1050;
public const EVENT_SOUND_ORB = 1051;
public const EVENT_SOUND_TOTEM = 1052;
public const EVENT_SOUND_ARMOR_STAND_BREAK = 1060;
public const EVENT_SOUND_ARMOR_STAND_HIT = 1061;
public const EVENT_SOUND_ARMOR_STAND_FALL = 1062;
public const EVENT_SOUND_ARMOR_STAND_PLACE = 1063;
//TODO: check 2000-2017
public const EVENT_PARTICLE_SHOOT = 2000;
public const EVENT_PARTICLE_DESTROY = 2001;
public const EVENT_PARTICLE_SPLASH = 2002;
public const EVENT_PARTICLE_EYE_DESPAWN = 2003;
public const EVENT_PARTICLE_SPAWN = 2004;
public const EVENT_GUARDIAN_CURSE = 2006;
public const EVENT_PARTICLE_BLOCK_FORCE_FIELD = 2008;
public const EVENT_PARTICLE_PROJECTILE_HIT = 2009;
public const EVENT_PARTICLE_DRAGON_EGG_TELEPORT = 2010;
public const EVENT_PARTICLE_ENDERMAN_TELEPORT = 2013;
public const EVENT_PARTICLE_PUNCH_BLOCK = 2014;
public const EVENT_START_RAIN = 3001;
public const EVENT_START_THUNDER = 3002;
public const EVENT_STOP_RAIN = 3003;
public const EVENT_STOP_THUNDER = 3004;
public const EVENT_PAUSE_GAME = 3005; //data: 1 to pause, 0 to resume
public const EVENT_PAUSE_GAME_NO_SCREEN = 3006; //data: 1 to pause, 0 to resume - same effect as normal pause but without screen
public const EVENT_SET_GAME_SPEED = 3007; //x coordinate of pos = scale factor (default 1.0)
public const EVENT_REDSTONE_TRIGGER = 3500;
public const EVENT_CAULDRON_EXPLODE = 3501;
public const EVENT_CAULDRON_DYE_ARMOR = 3502;
public const EVENT_CAULDRON_CLEAN_ARMOR = 3503;
public const EVENT_CAULDRON_FILL_POTION = 3504;
public const EVENT_CAULDRON_TAKE_POTION = 3505;
public const EVENT_CAULDRON_FILL_WATER = 3506;
public const EVENT_CAULDRON_TAKE_WATER = 3507;
public const EVENT_CAULDRON_ADD_DYE = 3508;
public const EVENT_CAULDRON_CLEAN_BANNER = 3509;
public const EVENT_BLOCK_START_BREAK = 3600;
public const EVENT_BLOCK_STOP_BREAK = 3601;
public const EVENT_SET_DATA = 4000;
public const EVENT_PLAYERS_SLEEPING = 9800;
public const EVENT_ADD_PARTICLE_MASK = 0x4000;
/** @var int */
public $evid;
/** @var Vector3|null */
public $position;
/** @var int */
public $data;
public static function create(int $evid, int $data, ?Vector3 $pos) : self{
$pk = new self;
$pk->evid = $evid;
$pk->data = $data;
$pk->position = $pos !== null ? $pos->asVector3() : null;
return $pk;
}
public static function standardParticle(int $particleId, int $data, Vector3 $pos) : self{
return self::create(self::EVENT_ADD_PARTICLE_MASK | $particleId, $data, $pos);
}
protected function decodePayload(PacketSerializer $in) : void{
$this->evid = $in->getVarInt();
$this->position = $in->getVector3();
$this->data = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->evid);
$out->putVector3Nullable($this->position);
$out->putVarInt($this->data);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelEvent($this);
}
}

View File

@ -1,408 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET;
public const SOUND_ITEM_USE_ON = 0;
public const SOUND_HIT = 1;
public const SOUND_STEP = 2;
public const SOUND_FLY = 3;
public const SOUND_JUMP = 4;
public const SOUND_BREAK = 5;
public const SOUND_PLACE = 6;
public const SOUND_HEAVY_STEP = 7;
public const SOUND_GALLOP = 8;
public const SOUND_FALL = 9;
public const SOUND_AMBIENT = 10;
public const SOUND_AMBIENT_BABY = 11;
public const SOUND_AMBIENT_IN_WATER = 12;
public const SOUND_BREATHE = 13;
public const SOUND_DEATH = 14;
public const SOUND_DEATH_IN_WATER = 15;
public const SOUND_DEATH_TO_ZOMBIE = 16;
public const SOUND_HURT = 17;
public const SOUND_HURT_IN_WATER = 18;
public const SOUND_MAD = 19;
public const SOUND_BOOST = 20;
public const SOUND_BOW = 21;
public const SOUND_SQUISH_BIG = 22;
public const SOUND_SQUISH_SMALL = 23;
public const SOUND_FALL_BIG = 24;
public const SOUND_FALL_SMALL = 25;
public const SOUND_SPLASH = 26;
public const SOUND_FIZZ = 27;
public const SOUND_FLAP = 28;
public const SOUND_SWIM = 29;
public const SOUND_DRINK = 30;
public const SOUND_EAT = 31;
public const SOUND_TAKEOFF = 32;
public const SOUND_SHAKE = 33;
public const SOUND_PLOP = 34;
public const SOUND_LAND = 35;
public const SOUND_SADDLE = 36;
public const SOUND_ARMOR = 37;
public const SOUND_MOB_ARMOR_STAND_PLACE = 38;
public const SOUND_ADD_CHEST = 39;
public const SOUND_THROW = 40;
public const SOUND_ATTACK = 41;
public const SOUND_ATTACK_NODAMAGE = 42;
public const SOUND_ATTACK_STRONG = 43;
public const SOUND_WARN = 44;
public const SOUND_SHEAR = 45;
public const SOUND_MILK = 46;
public const SOUND_THUNDER = 47;
public const SOUND_EXPLODE = 48;
public const SOUND_FIRE = 49;
public const SOUND_IGNITE = 50;
public const SOUND_FUSE = 51;
public const SOUND_STARE = 52;
public const SOUND_SPAWN = 53;
public const SOUND_SHOOT = 54;
public const SOUND_BREAK_BLOCK = 55;
public const SOUND_LAUNCH = 56;
public const SOUND_BLAST = 57;
public const SOUND_LARGE_BLAST = 58;
public const SOUND_TWINKLE = 59;
public const SOUND_REMEDY = 60;
public const SOUND_UNFECT = 61;
public const SOUND_LEVELUP = 62;
public const SOUND_BOW_HIT = 63;
public const SOUND_BULLET_HIT = 64;
public const SOUND_EXTINGUISH_FIRE = 65;
public const SOUND_ITEM_FIZZ = 66;
public const SOUND_CHEST_OPEN = 67;
public const SOUND_CHEST_CLOSED = 68;
public const SOUND_SHULKERBOX_OPEN = 69;
public const SOUND_SHULKERBOX_CLOSED = 70;
public const SOUND_ENDERCHEST_OPEN = 71;
public const SOUND_ENDERCHEST_CLOSED = 72;
public const SOUND_POWER_ON = 73;
public const SOUND_POWER_OFF = 74;
public const SOUND_ATTACH = 75;
public const SOUND_DETACH = 76;
public const SOUND_DENY = 77;
public const SOUND_TRIPOD = 78;
public const SOUND_POP = 79;
public const SOUND_DROP_SLOT = 80;
public const SOUND_NOTE = 81;
public const SOUND_THORNS = 82;
public const SOUND_PISTON_IN = 83;
public const SOUND_PISTON_OUT = 84;
public const SOUND_PORTAL = 85;
public const SOUND_WATER = 86;
public const SOUND_LAVA_POP = 87;
public const SOUND_LAVA = 88;
public const SOUND_BURP = 89;
public const SOUND_BUCKET_FILL_WATER = 90;
public const SOUND_BUCKET_FILL_LAVA = 91;
public const SOUND_BUCKET_EMPTY_WATER = 92;
public const SOUND_BUCKET_EMPTY_LAVA = 93;
public const SOUND_ARMOR_EQUIP_CHAIN = 94;
public const SOUND_ARMOR_EQUIP_DIAMOND = 95;
public const SOUND_ARMOR_EQUIP_GENERIC = 96;
public const SOUND_ARMOR_EQUIP_GOLD = 97;
public const SOUND_ARMOR_EQUIP_IRON = 98;
public const SOUND_ARMOR_EQUIP_LEATHER = 99;
public const SOUND_ARMOR_EQUIP_ELYTRA = 100;
public const SOUND_RECORD_13 = 101;
public const SOUND_RECORD_CAT = 102;
public const SOUND_RECORD_BLOCKS = 103;
public const SOUND_RECORD_CHIRP = 104;
public const SOUND_RECORD_FAR = 105;
public const SOUND_RECORD_MALL = 106;
public const SOUND_RECORD_MELLOHI = 107;
public const SOUND_RECORD_STAL = 108;
public const SOUND_RECORD_STRAD = 109;
public const SOUND_RECORD_WARD = 110;
public const SOUND_RECORD_11 = 111;
public const SOUND_RECORD_WAIT = 112;
public const SOUND_STOP_RECORD = 113; //Not really a sound
public const SOUND_FLOP = 114;
public const SOUND_ELDERGUARDIAN_CURSE = 115;
public const SOUND_MOB_WARNING = 116;
public const SOUND_MOB_WARNING_BABY = 117;
public const SOUND_TELEPORT = 118;
public const SOUND_SHULKER_OPEN = 119;
public const SOUND_SHULKER_CLOSE = 120;
public const SOUND_HAGGLE = 121;
public const SOUND_HAGGLE_YES = 122;
public const SOUND_HAGGLE_NO = 123;
public const SOUND_HAGGLE_IDLE = 124;
public const SOUND_CHORUSGROW = 125;
public const SOUND_CHORUSDEATH = 126;
public const SOUND_GLASS = 127;
public const SOUND_POTION_BREWED = 128;
public const SOUND_CAST_SPELL = 129;
public const SOUND_PREPARE_ATTACK = 130;
public const SOUND_PREPARE_SUMMON = 131;
public const SOUND_PREPARE_WOLOLO = 132;
public const SOUND_FANG = 133;
public const SOUND_CHARGE = 134;
public const SOUND_CAMERA_TAKE_PICTURE = 135;
public const SOUND_LEASHKNOT_PLACE = 136;
public const SOUND_LEASHKNOT_BREAK = 137;
public const SOUND_GROWL = 138;
public const SOUND_WHINE = 139;
public const SOUND_PANT = 140;
public const SOUND_PURR = 141;
public const SOUND_PURREOW = 142;
public const SOUND_DEATH_MIN_VOLUME = 143;
public const SOUND_DEATH_MID_VOLUME = 144;
public const SOUND_IMITATE_BLAZE = 145;
public const SOUND_IMITATE_CAVE_SPIDER = 146;
public const SOUND_IMITATE_CREEPER = 147;
public const SOUND_IMITATE_ELDER_GUARDIAN = 148;
public const SOUND_IMITATE_ENDER_DRAGON = 149;
public const SOUND_IMITATE_ENDERMAN = 150;
public const SOUND_IMITATE_EVOCATION_ILLAGER = 152;
public const SOUND_IMITATE_GHAST = 153;
public const SOUND_IMITATE_HUSK = 154;
public const SOUND_IMITATE_ILLUSION_ILLAGER = 155;
public const SOUND_IMITATE_MAGMA_CUBE = 156;
public const SOUND_IMITATE_POLAR_BEAR = 157;
public const SOUND_IMITATE_SHULKER = 158;
public const SOUND_IMITATE_SILVERFISH = 159;
public const SOUND_IMITATE_SKELETON = 160;
public const SOUND_IMITATE_SLIME = 161;
public const SOUND_IMITATE_SPIDER = 162;
public const SOUND_IMITATE_STRAY = 163;
public const SOUND_IMITATE_VEX = 164;
public const SOUND_IMITATE_VINDICATION_ILLAGER = 165;
public const SOUND_IMITATE_WITCH = 166;
public const SOUND_IMITATE_WITHER = 167;
public const SOUND_IMITATE_WITHER_SKELETON = 168;
public const SOUND_IMITATE_WOLF = 169;
public const SOUND_IMITATE_ZOMBIE = 170;
public const SOUND_IMITATE_ZOMBIE_PIGMAN = 171;
public const SOUND_IMITATE_ZOMBIE_VILLAGER = 172;
public const SOUND_BLOCK_END_PORTAL_FRAME_FILL = 173;
public const SOUND_BLOCK_END_PORTAL_SPAWN = 174;
public const SOUND_RANDOM_ANVIL_USE = 175;
public const SOUND_BOTTLE_DRAGONBREATH = 176;
public const SOUND_PORTAL_TRAVEL = 177;
public const SOUND_ITEM_TRIDENT_HIT = 178;
public const SOUND_ITEM_TRIDENT_RETURN = 179;
public const SOUND_ITEM_TRIDENT_RIPTIDE_1 = 180;
public const SOUND_ITEM_TRIDENT_RIPTIDE_2 = 181;
public const SOUND_ITEM_TRIDENT_RIPTIDE_3 = 182;
public const SOUND_ITEM_TRIDENT_THROW = 183;
public const SOUND_ITEM_TRIDENT_THUNDER = 184;
public const SOUND_ITEM_TRIDENT_HIT_GROUND = 185;
public const SOUND_DEFAULT = 186;
public const SOUND_BLOCK_FLETCHING_TABLE_USE = 187;
public const SOUND_ELEMCONSTRUCT_OPEN = 188;
public const SOUND_ICEBOMB_HIT = 189;
public const SOUND_BALLOONPOP = 190;
public const SOUND_LT_REACTION_ICEBOMB = 191;
public const SOUND_LT_REACTION_BLEACH = 192;
public const SOUND_LT_REACTION_EPASTE = 193;
public const SOUND_LT_REACTION_EPASTE2 = 194;
public const SOUND_LT_REACTION_FERTILIZER = 199;
public const SOUND_LT_REACTION_FIREBALL = 200;
public const SOUND_LT_REACTION_MGSALT = 201;
public const SOUND_LT_REACTION_MISCFIRE = 202;
public const SOUND_LT_REACTION_FIRE = 203;
public const SOUND_LT_REACTION_MISCEXPLOSION = 204;
public const SOUND_LT_REACTION_MISCMYSTICAL = 205;
public const SOUND_LT_REACTION_MISCMYSTICAL2 = 206;
public const SOUND_LT_REACTION_PRODUCT = 207;
public const SOUND_SPARKLER_USE = 208;
public const SOUND_GLOWSTICK_USE = 209;
public const SOUND_SPARKLER_ACTIVE = 210;
public const SOUND_CONVERT_TO_DROWNED = 211;
public const SOUND_BUCKET_FILL_FISH = 212;
public const SOUND_BUCKET_EMPTY_FISH = 213;
public const SOUND_BUBBLE_UP = 214;
public const SOUND_BUBBLE_DOWN = 215;
public const SOUND_BUBBLE_POP = 216;
public const SOUND_BUBBLE_UPINSIDE = 217;
public const SOUND_BUBBLE_DOWNINSIDE = 218;
public const SOUND_HURT_BABY = 219;
public const SOUND_DEATH_BABY = 220;
public const SOUND_STEP_BABY = 221;
public const SOUND_BORN = 223;
public const SOUND_BLOCK_TURTLE_EGG_BREAK = 224;
public const SOUND_BLOCK_TURTLE_EGG_CRACK = 225;
public const SOUND_BLOCK_TURTLE_EGG_HATCH = 226;
public const SOUND_LAY_EGG = 227;
public const SOUND_BLOCK_TURTLE_EGG_ATTACK = 228;
public const SOUND_BEACON_ACTIVATE = 229;
public const SOUND_BEACON_AMBIENT = 230;
public const SOUND_BEACON_DEACTIVATE = 231;
public const SOUND_BEACON_POWER = 232;
public const SOUND_CONDUIT_ACTIVATE = 233;
public const SOUND_CONDUIT_AMBIENT = 234;
public const SOUND_CONDUIT_ATTACK = 235;
public const SOUND_CONDUIT_DEACTIVATE = 236;
public const SOUND_CONDUIT_SHORT = 237;
public const SOUND_SWOOP = 238;
public const SOUND_BLOCK_BAMBOO_SAPLING_PLACE = 239;
public const SOUND_PRESNEEZE = 240;
public const SOUND_SNEEZE = 241;
public const SOUND_AMBIENT_TAME = 242;
public const SOUND_SCARED = 243;
public const SOUND_BLOCK_SCAFFOLDING_CLIMB = 244;
public const SOUND_CROSSBOW_LOADING_START = 245;
public const SOUND_CROSSBOW_LOADING_MIDDLE = 246;
public const SOUND_CROSSBOW_LOADING_END = 247;
public const SOUND_CROSSBOW_SHOOT = 248;
public const SOUND_CROSSBOW_QUICK_CHARGE_START = 249;
public const SOUND_CROSSBOW_QUICK_CHARGE_MIDDLE = 250;
public const SOUND_CROSSBOW_QUICK_CHARGE_END = 251;
public const SOUND_AMBIENT_AGGRESSIVE = 252;
public const SOUND_AMBIENT_WORRIED = 253;
public const SOUND_CANT_BREED = 254;
public const SOUND_ITEM_SHIELD_BLOCK = 255;
public const SOUND_ITEM_BOOK_PUT = 256;
public const SOUND_BLOCK_GRINDSTONE_USE = 257;
public const SOUND_BLOCK_BELL_HIT = 258;
public const SOUND_BLOCK_CAMPFIRE_CRACKLE = 259;
public const SOUND_ROAR = 260;
public const SOUND_STUN = 261;
public const SOUND_BLOCK_SWEET_BERRY_BUSH_HURT = 262;
public const SOUND_BLOCK_SWEET_BERRY_BUSH_PICK = 263;
public const SOUND_BLOCK_CARTOGRAPHY_TABLE_USE = 264;
public const SOUND_BLOCK_STONECUTTER_USE = 265;
public const SOUND_BLOCK_COMPOSTER_EMPTY = 266;
public const SOUND_BLOCK_COMPOSTER_FILL = 267;
public const SOUND_BLOCK_COMPOSTER_FILL_SUCCESS = 268;
public const SOUND_BLOCK_COMPOSTER_READY = 269;
public const SOUND_BLOCK_BARREL_OPEN = 270;
public const SOUND_BLOCK_BARREL_CLOSE = 271;
public const SOUND_RAID_HORN = 272;
public const SOUND_BLOCK_LOOM_USE = 273;
public const SOUND_AMBIENT_IN_RAID = 274;
public const SOUND_UI_CARTOGRAPHY_TABLE_TAKE_RESULT = 275;
public const SOUND_UI_STONECUTTER_TAKE_RESULT = 276;
public const SOUND_UI_LOOM_TAKE_RESULT = 277;
public const SOUND_BLOCK_SMOKER_SMOKE = 278;
public const SOUND_BLOCK_BLASTFURNACE_FIRE_CRACKLE = 279;
public const SOUND_BLOCK_SMITHING_TABLE_USE = 280;
public const SOUND_SCREECH = 281;
public const SOUND_SLEEP = 282;
public const SOUND_BLOCK_FURNACE_LIT = 283;
public const SOUND_CONVERT_MOOSHROOM = 284;
public const SOUND_MILK_SUSPICIOUSLY = 285;
public const SOUND_CELEBRATE = 286;
public const SOUND_JUMP_PREVENT = 287;
public const SOUND_AMBIENT_POLLINATE = 288;
public const SOUND_BLOCK_BEEHIVE_DRIP = 289;
public const SOUND_BLOCK_BEEHIVE_ENTER = 290;
public const SOUND_BLOCK_BEEHIVE_EXIT = 291;
public const SOUND_BLOCK_BEEHIVE_WORK = 292;
public const SOUND_BLOCK_BEEHIVE_SHEAR = 293;
public const SOUND_DRINK_HONEY = 294;
public const SOUND_AMBIENT_CAVE = 295;
public const SOUND_RETREAT = 296;
public const SOUND_CONVERTED_TO_ZOMBIFIED = 297;
public const SOUND_ADMIRE = 298;
public const SOUND_STEP_LAVA = 299;
public const SOUND_TEMPT = 300;
public const SOUND_PANIC = 301;
public const SOUND_ANGRY = 302;
public const SOUND_AMBIENT_WARPED_FOREST_MOOD = 303;
public const SOUND_AMBIENT_SOULSAND_VALLEY_MOOD = 304;
public const SOUND_AMBIENT_NETHER_WASTES_MOOD = 305;
public const SOUND_RESPAWN_ANCHOR_BASALT_DELTAS_MOOD = 306;
public const SOUND_AMBIENT_CRIMSON_FOREST_MOOD = 307;
public const SOUND_RESPAWN_ANCHOR_CHARGE = 308;
public const SOUND_RESPAWN_ANCHOR_DEPLETE = 309;
public const SOUND_RESPAWN_ANCHOR_SET_SPAWN = 310;
public const SOUND_RESPAWN_ANCHOR_AMBIENT = 311;
public const SOUND_PARTICLE_SOUL_ESCAPE_QUIET = 312;
public const SOUND_PARTICLE_SOUL_ESCAPE_LOUD = 313;
public const SOUND_RECORD_PIGSTEP = 314;
public const SOUND_LODESTONE_COMPASS_LINK_COMPASS_TO_LODESTONE = 315;
public const SOUND_SMITHING_TABLE_USE = 316;
public const SOUND_ARMOR_EQUIP_NETHERITE = 317;
public const SOUND_AMBIENT_WARPED_FOREST_LOOP = 318;
public const SOUND_AMBIENT_SOULSAND_VALLEY_LOOP = 319;
public const SOUND_AMBIENT_NETHER_WASTES_LOOP = 320;
public const SOUND_AMBIENT_BASALT_DELTAS_LOOP = 321;
public const SOUND_AMBIENT_CRIMSON_FOREST_LOOP = 322;
public const SOUND_AMBIENT_WARPED_FOREST_ADDITIONS = 323;
public const SOUND_AMBIENT_SOULSAND_VALLEY_ADDITIONS = 324;
public const SOUND_AMBIENT_NETHER_WASTES_ADDITIONS = 325;
public const SOUND_AMBIENT_BASALT_DELTAS_ADDITIONS = 326;
public const SOUND_AMBIENT_CRIMSON_FOREST_ADDITIONS = 327;
public const SOUND_BUCKET_FILL_POWDER_SNOW = 328;
public const SOUND_BUCKET_EMPTY_POWDER_SNOW = 329;
public const SOUND_UNDEFINED = 330;
public static function create(int $sound, ?Vector3 $pos, int $extraData = -1, string $entityType = ":", bool $isBabyMob = false) : self{
$result = new self;
$result->sound = $sound;
$result->extraData = $extraData;
$result->position = $pos ?? new Vector3(0, 0, 0);
$result->disableRelativeVolume = $pos === null;
$result->entityType = $entityType;
$result->isBabyMob = $isBabyMob;
return $result;
}
/** @var int */
public $sound;
/** @var Vector3 */
public $position;
/** @var int */
public $extraData = -1;
/** @var string */
public $entityType = ":"; //???
/** @var bool */
public $isBabyMob = false; //...
/** @var bool */
public $disableRelativeVolume = false;
protected function decodePayload(PacketSerializer $in) : void{
$this->sound = $in->getUnsignedVarInt();
$this->position = $in->getVector3();
$this->extraData = $in->getVarInt();
$this->entityType = $in->getString();
$this->isBabyMob = $in->getBool();
$this->disableRelativeVolume = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->sound);
$out->putVector3($this->position);
$out->putVarInt($this->extraData);
$out->putString($this->entityType);
$out->putBool($this->isBabyMob);
$out->putBool($this->disableRelativeVolume);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelSoundEvent($this);
}
}

View File

@ -1,71 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
/**
* Useless leftover from a 1.8 refactor, does nothing
*/
class LevelSoundEventPacketV1 extends DataPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V1;
/** @var int */
public $sound;
/** @var Vector3 */
public $position;
/** @var int */
public $extraData = 0;
/** @var int */
public $entityType = 1;
/** @var bool */
public $isBabyMob = false; //...
/** @var bool */
public $disableRelativeVolume = false;
protected function decodePayload(PacketSerializer $in) : void{
$this->sound = $in->getByte();
$this->position = $in->getVector3();
$this->extraData = $in->getVarInt();
$this->entityType = $in->getVarInt();
$this->isBabyMob = $in->getBool();
$this->disableRelativeVolume = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->sound);
$out->putVector3($this->position);
$out->putVarInt($this->extraData);
$out->putVarInt($this->entityType);
$out->putBool($this->isBabyMob);
$out->putBool($this->disableRelativeVolume);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelSoundEventPacketV1($this);
}
}

View File

@ -1,71 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
/**
* Useless leftover from a 1.9 refactor, does nothing
*/
class LevelSoundEventPacketV2 extends DataPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V2;
/** @var int */
public $sound;
/** @var Vector3 */
public $position;
/** @var int */
public $extraData = -1;
/** @var string */
public $entityType = ":"; //???
/** @var bool */
public $isBabyMob = false; //...
/** @var bool */
public $disableRelativeVolume = false;
protected function decodePayload(PacketSerializer $in) : void{
$this->sound = $in->getByte();
$this->position = $in->getVector3();
$this->extraData = $in->getVarInt();
$this->entityType = $in->getString();
$this->isBabyMob = $in->getBool();
$this->disableRelativeVolume = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->sound);
$out->putVector3($this->position);
$out->putVarInt($this->extraData);
$out->putString($this->entityType);
$out->putBool($this->isBabyMob);
$out->putBool($this->disableRelativeVolume);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLevelSoundEventPacketV2($this);
}
}

View File

@ -1,101 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\login\JwtChain;
use pocketmine\utils\BinaryStream;
use function is_object;
use function json_decode;
use function json_encode;
use function json_last_error_msg;
use function strlen;
class LoginPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::LOGIN_PACKET;
/** @var int */
public $protocol;
/** @var JwtChain */
public $chainDataJwt;
/** @var string */
public $clientDataJwt;
public function canBeSentBeforeLogin() : bool{
return true;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->protocol = $in->getInt();
$this->decodeConnectionRequest($in->getString());
}
protected function decodeConnectionRequest(string $binary) : void{
$connRequestReader = new BinaryStream($binary);
$chainDataJson = json_decode($connRequestReader->get($connRequestReader->getLInt()));
if(!is_object($chainDataJson)){
throw new PacketDecodeException("Failed decoding chain data JSON: " . json_last_error_msg());
}
$mapper = new \JsonMapper;
$mapper->bExceptionOnMissingData = true;
$mapper->bExceptionOnUndefinedProperty = true;
try{
$chainData = $mapper->map($chainDataJson, new JwtChain);
}catch(\JsonMapper_Exception $e){
throw PacketDecodeException::wrap($e);
}
$this->chainDataJwt = $chainData;
$this->clientDataJwt = $connRequestReader->get($connRequestReader->getLInt());
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putInt($this->protocol);
$out->putString($this->encodeConnectionRequest());
}
protected function encodeConnectionRequest() : string{
$connRequestWriter = new BinaryStream();
$chainDataJson = json_encode($this->chainDataJwt);
if($chainDataJson === false){
throw new \InvalidStateException("Failed to encode chain data JSON: " . json_last_error_msg());
}
$connRequestWriter->putLInt(strlen($chainDataJson));
$connRequestWriter->put($chainDataJson);
$connRequestWriter->putLInt(strlen($this->clientDataJwt));
$connRequestWriter->put($this->clientDataJwt);
return $connRequestWriter->getBuffer();
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleLogin($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MAP_CREATE_LOCKED_COPY_PACKET;
/** @var int */
public $originalMapId;
/** @var int */
public $newMapId;
protected function decodePayload(PacketSerializer $in) : void{
$this->originalMapId = $in->getEntityUniqueId();
$this->newMapId = $in->getEntityUniqueId();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->originalMapId);
$out->putEntityUniqueId($this->newMapId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMapCreateLockedCopy($this);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET;
/** @var int */
public $mapId;
protected function decodePayload(PacketSerializer $in) : void{
$this->mapId = $in->getEntityUniqueId();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->mapId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMapInfoRequest($this);
}
}

View File

@ -1,78 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
/** @var int */
public $entityRuntimeId;
//this intentionally doesn't use an array because we don't want any implicit dependencies on internal order
/** @var ItemStackWrapper */
public $head;
/** @var ItemStackWrapper */
public $chest;
/** @var ItemStackWrapper */
public $legs;
/** @var ItemStackWrapper */
public $feet;
public static function create(int $entityRuntimeId, ItemStackWrapper $head, ItemStackWrapper $chest, ItemStackWrapper $legs, ItemStackWrapper $feet) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->head = $head;
$result->chest = $chest;
$result->legs = $legs;
$result->feet = $feet;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->head = ItemStackWrapper::read($in);
$this->chest = ItemStackWrapper::read($in);
$this->legs = ItemStackWrapper::read($in);
$this->feet = ItemStackWrapper::read($in);
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$this->head->write($out);
$this->chest->write($out);
$this->legs->write($out);
$this->feet->write($out);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMobArmorEquipment($this);
}
}

View File

@ -1,90 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MobEffectPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET;
public const EVENT_ADD = 1;
public const EVENT_MODIFY = 2;
public const EVENT_REMOVE = 3;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $eventId;
/** @var int */
public $effectId;
/** @var int */
public $amplifier = 0;
/** @var bool */
public $particles = true;
/** @var int */
public $duration = 0;
public static function add(int $entityRuntimeId, bool $replace, int $effectId, int $amplifier, bool $particles, int $duration) : self{
$result = new self;
$result->eventId = $replace ? self::EVENT_MODIFY : self::EVENT_ADD;
$result->entityRuntimeId = $entityRuntimeId;
$result->effectId = $effectId;
$result->amplifier = $amplifier;
$result->particles = $particles;
$result->duration = $duration;
return $result;
}
public static function remove(int $entityRuntimeId, int $effectId) : self{
$pk = new self;
$pk->eventId = self::EVENT_REMOVE;
$pk->entityRuntimeId = $entityRuntimeId;
$pk->effectId = $effectId;
return $pk;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->eventId = $in->getByte();
$this->effectId = $in->getVarInt();
$this->amplifier = $in->getVarInt();
$this->particles = $in->getBool();
$this->duration = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putByte($this->eventId);
$out->putVarInt($this->effectId);
$out->putVarInt($this->amplifier);
$out->putBool($this->particles);
$out->putVarInt($this->duration);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMobEffect($this);
}
}

View File

@ -1,74 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
class MobEquipmentPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
/** @var int */
public $entityRuntimeId;
/** @var ItemStackWrapper */
public $item;
/** @var int */
public $inventorySlot;
/** @var int */
public $hotbarSlot;
/** @var int */
public $windowId = 0;
public static function create(int $entityRuntimeId, ItemStackWrapper $item, int $inventorySlot, int $windowId) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->item = $item;
$result->inventorySlot = $inventorySlot;
$result->hotbarSlot = $inventorySlot;
$result->windowId = $windowId;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->item = ItemStackWrapper::read($in);
$this->inventorySlot = $in->getByte();
$this->hotbarSlot = $in->getByte();
$this->windowId = $in->getByte();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$this->item->write($out);
$out->putByte($this->inventorySlot);
$out->putByte($this->hotbarSlot);
$out->putByte($this->windowId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMobEquipment($this);
}
}

View File

@ -1,58 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET;
/** @var int */
public $formId;
/** @var string */
public $formData; //json
public static function create(int $formId, string $formData) : self{
$result = new self;
$result->formId = $formId;
$result->formData = $formData;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->formId = $in->getUnsignedVarInt();
$this->formData = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->formId);
$out->putString($this->formData);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleModalFormRequest($this);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET;
/** @var int */
public $formId;
/** @var string */
public $formData; //json
protected function decodePayload(PacketSerializer $in) : void{
$this->formId = $in->getUnsignedVarInt();
$this->formData = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->formId);
$out->putString($this->formData);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleModalFormResponse($this);
}
}

View File

@ -1,70 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MotionPredictionHintsPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::MOTION_PREDICTION_HINTS_PACKET;
/** @var int */
private $entityRuntimeId;
/** @var Vector3 */
private $motion;
/** @var bool */
private $onGround;
public static function create(int $entityRuntimeId, Vector3 $motion, bool $onGround) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->motion = $motion;
$result->onGround = $onGround;
return $result;
}
public function getEntityRuntimeId() : int{ return $this->entityRuntimeId; }
public function getMotion() : Vector3{ return $this->motion; }
public function isOnGround() : bool{ return $this->onGround; }
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->motion = $in->getVector3();
$this->onGround = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putVector3($this->motion);
$out->putBool($this->onGround);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMotionPredictionHints($this);
}
}

View File

@ -1,83 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_ABSOLUTE_PACKET;
public const FLAG_GROUND = 0x01;
public const FLAG_TELEPORT = 0x02;
public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x04;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $flags = 0;
/** @var Vector3 */
public $position;
/** @var float */
public $xRot;
/** @var float */
public $yRot;
/** @var float */
public $zRot;
public static function create(int $entityRuntimeId, Vector3 $pos, float $xRot, float $yRot, float $zRot, int $flags = 0) : self{
$result = new self;
$result->entityRuntimeId = $entityRuntimeId;
$result->position = $pos->asVector3();
$result->xRot = $xRot;
$result->yRot = $yRot;
$result->zRot = $zRot;
$result->flags = $flags;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->flags = $in->getByte();
$this->position = $in->getVector3();
$this->xRot = $in->getByteRotation();
$this->yRot = $in->getByteRotation();
$this->zRot = $in->getByteRotation();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putByte($this->flags);
$out->putVector3($this->position);
$out->putByteRotation($this->xRot);
$out->putByteRotation($this->yRot);
$out->putByteRotation($this->zRot);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMoveActorAbsolute($this);
}
}

View File

@ -1,118 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\utils\BinaryDataException;
class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::MOVE_ACTOR_DELTA_PACKET;
public const FLAG_HAS_X = 0x01;
public const FLAG_HAS_Y = 0x02;
public const FLAG_HAS_Z = 0x04;
public const FLAG_HAS_ROT_X = 0x08;
public const FLAG_HAS_ROT_Y = 0x10;
public const FLAG_HAS_ROT_Z = 0x20;
public const FLAG_GROUND = 0x40;
public const FLAG_TELEPORT = 0x80;
public const FLAG_FORCE_MOVE_LOCAL_ENTITY = 0x100;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $flags;
/** @var float */
public $xPos = 0;
/** @var float */
public $yPos = 0;
/** @var float */
public $zPos = 0;
/** @var float */
public $xRot = 0.0;
/** @var float */
public $yRot = 0.0;
/** @var float */
public $zRot = 0.0;
/**
* @throws BinaryDataException
*/
private function maybeReadCoord(int $flag, PacketSerializer $in) : float{
if(($this->flags & $flag) !== 0){
return $in->getLFloat();
}
return 0;
}
/**
* @throws BinaryDataException
*/
private function maybeReadRotation(int $flag, PacketSerializer $in) : float{
if(($this->flags & $flag) !== 0){
return $in->getByteRotation();
}
return 0.0;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->flags = $in->getLShort();
$this->xPos = $this->maybeReadCoord(self::FLAG_HAS_X, $in);
$this->yPos = $this->maybeReadCoord(self::FLAG_HAS_Y, $in);
$this->zPos = $this->maybeReadCoord(self::FLAG_HAS_Z, $in);
$this->xRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_X, $in);
$this->yRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Y, $in);
$this->zRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Z, $in);
}
private function maybeWriteCoord(int $flag, float $val, PacketSerializer $out) : void{
if(($this->flags & $flag) !== 0){
$out->putLFloat($val);
}
}
private function maybeWriteRotation(int $flag, float $val, PacketSerializer $out) : void{
if(($this->flags & $flag) !== 0){
$out->putByteRotation($val);
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putLShort($this->flags);
$this->maybeWriteCoord(self::FLAG_HAS_X, $this->xPos, $out);
$this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yPos, $out);
$this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zPos, $out);
$this->maybeWriteRotation(self::FLAG_HAS_ROT_X, $this->xRot, $out);
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Y, $this->yRot, $out);
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot, $out);
}
public function handle(PacketHandlerInterface $session) : bool{
return $session->handleMoveActorDelta($this);
}
}

View File

@ -1,97 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MovePlayerPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET;
public const MODE_NORMAL = 0;
public const MODE_RESET = 1;
public const MODE_TELEPORT = 2;
public const MODE_PITCH = 3; //facepalm Mojang
/** @var int */
public $entityRuntimeId;
/** @var Vector3 */
public $position;
/** @var float */
public $pitch;
/** @var float */
public $yaw;
/** @var float */
public $headYaw;
/** @var int */
public $mode = self::MODE_NORMAL;
/** @var bool */
public $onGround = false; //TODO
/** @var int */
public $ridingEid = 0;
/** @var int */
public $teleportCause = 0;
/** @var int */
public $teleportItem = 0;
/** @var int */
public $tick = 0;
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->position = $in->getVector3();
$this->pitch = $in->getLFloat();
$this->yaw = $in->getLFloat();
$this->headYaw = $in->getLFloat();
$this->mode = $in->getByte();
$this->onGround = $in->getBool();
$this->ridingEid = $in->getEntityRuntimeId();
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
$this->teleportCause = $in->getLInt();
$this->teleportItem = $in->getLInt();
}
$this->tick = $in->getUnsignedVarLong();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putVector3($this->position);
$out->putLFloat($this->pitch);
$out->putLFloat($this->yaw);
$out->putLFloat($this->headYaw); //TODO
$out->putByte($this->mode);
$out->putBool($this->onGround);
$out->putEntityRuntimeId($this->ridingEid);
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
$out->putLInt($this->teleportCause);
$out->putLInt($this->teleportItem);
}
$out->putUnsignedVarLong($this->tick);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMovePlayer($this);
}
}

View File

@ -1,61 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class MultiplayerSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::MULTIPLAYER_SETTINGS_PACKET;
public const ACTION_ENABLE_MULTIPLAYER = 0;
public const ACTION_DISABLE_MULTIPLAYER = 1;
public const ACTION_REFRESH_JOIN_CODE = 2;
/** @var int */
private $action;
public static function create(int $action) : self{
$result = new self;
$result->action = $action;
return $result;
}
public function getAction() : int{
return $this->action;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->action = $in->getVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->action);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleMultiplayerSettings($this);
}
}

View File

@ -1,64 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class NetworkChunkPublisherUpdatePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::NETWORK_CHUNK_PUBLISHER_UPDATE_PACKET;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $radius;
public static function create(int $x, int $y, int $z, int $blockRadius) : self{
$result = new self;
$result->x = $x;
$result->y = $y;
$result->z = $z;
$result->radius = $blockRadius;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$in->getSignedBlockPosition($this->x, $this->y, $this->z);
$this->radius = $in->getUnsignedVarInt();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putSignedBlockPosition($this->x, $this->y, $this->z);
$out->putUnsignedVarInt($this->radius);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleNetworkChunkPublisherUpdate($this);
}
}

View File

@ -1,60 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::NETWORK_SETTINGS_PACKET;
public const COMPRESS_NOTHING = 0;
public const COMPRESS_EVERYTHING = 1;
/** @var int */
private $compressionThreshold;
public static function create(int $compressionThreshold) : self{
$result = new self;
$result->compressionThreshold = $compressionThreshold;
return $result;
}
public function getCompressionThreshold() : int{
return $this->compressionThreshold;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->compressionThreshold = $in->getLShort();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLShort($this->compressionThreshold);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleNetworkSettings($this);
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::NETWORK_STACK_LATENCY_PACKET;
/** @var int */
public $timestamp;
/** @var bool */
public $needResponse;
public static function request(int $timestampNs) : self{
$result = new self;
$result->timestamp = $timestampNs;
$result->needResponse = true;
return $result;
}
public static function response(int $timestampNs) : self{
$result = new self;
$result->timestamp = $timestampNs;
$result->needResponse = false;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$this->timestamp = $in->getLLong();
$this->needResponse = $in->getBool();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLLong($this->timestamp);
$out->putBool($this->needResponse);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleNetworkStackLatency($this);
}
}

View File

@ -1,87 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class NpcDialoguePacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::NPC_DIALOGUE_PACKET;
public const ACTION_OPEN = 0;
public const ACTION_CLOSE = 1;
private int $npcActorUniqueId;
private int $actionType;
private string $dialogue;
private string $sceneName;
private string $npcName;
private string $actionJson;
public static function create(int $npcActorUniqueId, int $actionType, string $dialogue, string $sceneName, string $npcName, string $actionJson) : self{
$result = new self;
$result->npcActorUniqueId = $npcActorUniqueId;
$result->actionType = $actionType;
$result->dialogue = $dialogue;
$result->sceneName = $sceneName;
$result->npcName = $npcName;
$result->actionJson = $actionJson;
return $result;
}
public function getNpcActorUniqueId() : int{ return $this->npcActorUniqueId; }
public function getActionType() : int{ return $this->actionType; }
public function getDialogue() : string{ return $this->dialogue; }
public function getSceneName() : string{ return $this->sceneName; }
public function getNpcName() : string{ return $this->npcName; }
public function getActionJson() : string{ return $this->actionJson; }
protected function decodePayload(PacketSerializer $in) : void{
$this->npcActorUniqueId = $in->getEntityUniqueId();
$this->actionType = $in->getVarInt();
$this->dialogue = $in->getString();
$this->sceneName = $in->getString();
$this->npcName = $in->getString();
$this->actionJson = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityUniqueId($this->npcActorUniqueId);
$out->putVarInt($this->actionType);
$out->putString($this->dialogue);
$out->putString($this->sceneName);
$out->putString($this->npcName);
$out->putString($this->actionJson);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleNpcDialogue($this);
}
}

View File

@ -1,70 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class NpcRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET;
public const REQUEST_SET_ACTIONS = 0;
public const REQUEST_EXECUTE_ACTION = 1;
public const REQUEST_EXECUTE_CLOSING_COMMANDS = 2;
public const REQUEST_SET_NAME = 3;
public const REQUEST_SET_SKIN = 4;
public const REQUEST_SET_INTERACTION_TEXT = 5;
public const REQUEST_EXECUTE_OPENING_COMMANDS = 6;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $requestType;
/** @var string */
public $commandString;
/** @var int */
public $actionType;
public string $sceneName;
protected function decodePayload(PacketSerializer $in) : void{
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->requestType = $in->getByte();
$this->commandString = $in->getString();
$this->actionType = $in->getByte();
$this->sceneName = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putEntityRuntimeId($this->entityRuntimeId);
$out->putByte($this->requestType);
$out->putString($this->commandString);
$out->putByte($this->actionType);
$out->putString($this->sceneName);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleNpcRequest($this);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ON_SCREEN_TEXTURE_ANIMATION_PACKET;
/** @var int */
public $effectId;
protected function decodePayload(PacketSerializer $in) : void{
$this->effectId = $in->getLInt(); //unsigned
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putLInt($this->effectId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleOnScreenTextureAnimation($this);
}
}

View File

@ -1,57 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
interface Packet{
public function pid() : int;
public function getName() : string;
public function canBeSentBeforeLogin() : bool;
/**
* @throws PacketDecodeException
*/
public function decode(PacketSerializer $in) : void;
public function encode(PacketSerializer $out) : void;
/**
* Performs handling for this packet. Usually you'll want an appropriately named method in the session handler for
* this.
*
* This method returns a bool to indicate whether the packet was handled or not. If the packet was unhandled, a
* debug message will be logged with a hexdump of the packet.
*
* Typically this method returns the return value of the handler in the supplied PacketHandler. See other packets
* for examples how to implement this.
*
* @return bool true if the packet was handled successfully, false if not.
* @throws PacketDecodeException if broken data was found in the packet
*/
public function handle(PacketHandlerInterface $handler) : bool;
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
final class PacketDecodeException extends \RuntimeException{
public static function wrap(\Throwable $previous, ?string $prefix = null) : self{
return new self(($prefix !== null ? $prefix . ": " : "") . $previous->getMessage(), 0, $previous);
}
}

View File

@ -1,357 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
/**
* This class is an automatically generated stub. Do not edit it manually.
*/
interface PacketHandlerInterface{
public function handleLogin(LoginPacket $packet) : bool;
public function handlePlayStatus(PlayStatusPacket $packet) : bool;
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool;
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool;
public function handleDisconnect(DisconnectPacket $packet) : bool;
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool;
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool;
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool;
public function handleText(TextPacket $packet) : bool;
public function handleSetTime(SetTimePacket $packet) : bool;
public function handleStartGame(StartGamePacket $packet) : bool;
public function handleAddPlayer(AddPlayerPacket $packet) : bool;
public function handleAddActor(AddActorPacket $packet) : bool;
public function handleRemoveActor(RemoveActorPacket $packet) : bool;
public function handleAddItemActor(AddItemActorPacket $packet) : bool;
public function handleTakeItemActor(TakeItemActorPacket $packet) : bool;
public function handleMoveActorAbsolute(MoveActorAbsolutePacket $packet) : bool;
public function handleMovePlayer(MovePlayerPacket $packet) : bool;
public function handleRiderJump(RiderJumpPacket $packet) : bool;
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool;
public function handleAddPainting(AddPaintingPacket $packet) : bool;
public function handleTickSync(TickSyncPacket $packet) : bool;
public function handleLevelSoundEventPacketV1(LevelSoundEventPacketV1 $packet) : bool;
public function handleLevelEvent(LevelEventPacket $packet) : bool;
public function handleBlockEvent(BlockEventPacket $packet) : bool;
public function handleActorEvent(ActorEventPacket $packet) : bool;
public function handleMobEffect(MobEffectPacket $packet) : bool;
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool;
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool;
public function handleMobEquipment(MobEquipmentPacket $packet) : bool;
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool;
public function handleInteract(InteractPacket $packet) : bool;
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool;
public function handleActorPickRequest(ActorPickRequestPacket $packet) : bool;
public function handlePlayerAction(PlayerActionPacket $packet) : bool;
public function handleHurtArmor(HurtArmorPacket $packet) : bool;
public function handleSetActorData(SetActorDataPacket $packet) : bool;
public function handleSetActorMotion(SetActorMotionPacket $packet) : bool;
public function handleSetActorLink(SetActorLinkPacket $packet) : bool;
public function handleSetHealth(SetHealthPacket $packet) : bool;
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool;
public function handleAnimate(AnimatePacket $packet) : bool;
public function handleRespawn(RespawnPacket $packet) : bool;
public function handleContainerOpen(ContainerOpenPacket $packet) : bool;
public function handleContainerClose(ContainerClosePacket $packet) : bool;
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool;
public function handleInventoryContent(InventoryContentPacket $packet) : bool;
public function handleInventorySlot(InventorySlotPacket $packet) : bool;
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool;
public function handleCraftingData(CraftingDataPacket $packet) : bool;
public function handleCraftingEvent(CraftingEventPacket $packet) : bool;
public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool;
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool;
public function handleBlockActorData(BlockActorDataPacket $packet) : bool;
public function handlePlayerInput(PlayerInputPacket $packet) : bool;
public function handleLevelChunk(LevelChunkPacket $packet) : bool;
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool;
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool;
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool;
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool;
public function handlePlayerList(PlayerListPacket $packet) : bool;
public function handleSimpleEvent(SimpleEventPacket $packet) : bool;
public function handleEvent(EventPacket $packet) : bool;
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool;
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool;
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool;
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool;
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool;
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool;
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool;
public function handleCamera(CameraPacket $packet) : bool;
public function handleBossEvent(BossEventPacket $packet) : bool;
public function handleShowCredits(ShowCreditsPacket $packet) : bool;
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool;
public function handleCommandRequest(CommandRequestPacket $packet) : bool;
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool;
public function handleCommandOutput(CommandOutputPacket $packet) : bool;
public function handleUpdateTrade(UpdateTradePacket $packet) : bool;
public function handleUpdateEquip(UpdateEquipPacket $packet) : bool;
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool;
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool;
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool;
public function handleTransfer(TransferPacket $packet) : bool;
public function handlePlaySound(PlaySoundPacket $packet) : bool;
public function handleStopSound(StopSoundPacket $packet) : bool;
public function handleSetTitle(SetTitlePacket $packet) : bool;
public function handleAddBehaviorTree(AddBehaviorTreePacket $packet) : bool;
public function handleStructureBlockUpdate(StructureBlockUpdatePacket $packet) : bool;
public function handleShowStoreOffer(ShowStoreOfferPacket $packet) : bool;
public function handlePurchaseReceipt(PurchaseReceiptPacket $packet) : bool;
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool;
public function handleSubClientLogin(SubClientLoginPacket $packet) : bool;
public function handleAutomationClientConnect(AutomationClientConnectPacket $packet) : bool;
public function handleSetLastHurtBy(SetLastHurtByPacket $packet) : bool;
public function handleBookEdit(BookEditPacket $packet) : bool;
public function handleNpcRequest(NpcRequestPacket $packet) : bool;
public function handlePhotoTransfer(PhotoTransferPacket $packet) : bool;
public function handleModalFormRequest(ModalFormRequestPacket $packet) : bool;
public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool;
public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool;
public function handleServerSettingsResponse(ServerSettingsResponsePacket $packet) : bool;
public function handleShowProfile(ShowProfilePacket $packet) : bool;
public function handleSetDefaultGameType(SetDefaultGameTypePacket $packet) : bool;
public function handleRemoveObjective(RemoveObjectivePacket $packet) : bool;
public function handleSetDisplayObjective(SetDisplayObjectivePacket $packet) : bool;
public function handleSetScore(SetScorePacket $packet) : bool;
public function handleLabTable(LabTablePacket $packet) : bool;
public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool;
public function handleMoveActorDelta(MoveActorDeltaPacket $packet) : bool;
public function handleSetScoreboardIdentity(SetScoreboardIdentityPacket $packet) : bool;
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool;
public function handleUpdateSoftEnum(UpdateSoftEnumPacket $packet) : bool;
public function handleNetworkStackLatency(NetworkStackLatencyPacket $packet) : bool;
public function handleScriptCustomEvent(ScriptCustomEventPacket $packet) : bool;
public function handleSpawnParticleEffect(SpawnParticleEffectPacket $packet) : bool;
public function handleAvailableActorIdentifiers(AvailableActorIdentifiersPacket $packet) : bool;
public function handleLevelSoundEventPacketV2(LevelSoundEventPacketV2 $packet) : bool;
public function handleNetworkChunkPublisherUpdate(NetworkChunkPublisherUpdatePacket $packet) : bool;
public function handleBiomeDefinitionList(BiomeDefinitionListPacket $packet) : bool;
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool;
public function handleLevelEventGeneric(LevelEventGenericPacket $packet) : bool;
public function handleLecternUpdate(LecternUpdatePacket $packet) : bool;
public function handleAddEntity(AddEntityPacket $packet) : bool;
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool;
public function handleClientCacheStatus(ClientCacheStatusPacket $packet) : bool;
public function handleOnScreenTextureAnimation(OnScreenTextureAnimationPacket $packet) : bool;
public function handleMapCreateLockedCopy(MapCreateLockedCopyPacket $packet) : bool;
public function handleStructureTemplateDataRequest(StructureTemplateDataRequestPacket $packet) : bool;
public function handleStructureTemplateDataResponse(StructureTemplateDataResponsePacket $packet) : bool;
public function handleClientCacheBlobStatus(ClientCacheBlobStatusPacket $packet) : bool;
public function handleClientCacheMissResponse(ClientCacheMissResponsePacket $packet) : bool;
public function handleEducationSettings(EducationSettingsPacket $packet) : bool;
public function handleEmote(EmotePacket $packet) : bool;
public function handleMultiplayerSettings(MultiplayerSettingsPacket $packet) : bool;
public function handleSettingsCommand(SettingsCommandPacket $packet) : bool;
public function handleAnvilDamage(AnvilDamagePacket $packet) : bool;
public function handleCompletedUsingItem(CompletedUsingItemPacket $packet) : bool;
public function handleNetworkSettings(NetworkSettingsPacket $packet) : bool;
public function handlePlayerAuthInput(PlayerAuthInputPacket $packet) : bool;
public function handleCreativeContent(CreativeContentPacket $packet) : bool;
public function handlePlayerEnchantOptions(PlayerEnchantOptionsPacket $packet) : bool;
public function handleItemStackRequest(ItemStackRequestPacket $packet) : bool;
public function handleItemStackResponse(ItemStackResponsePacket $packet) : bool;
public function handlePlayerArmorDamage(PlayerArmorDamagePacket $packet) : bool;
public function handleCodeBuilder(CodeBuilderPacket $packet) : bool;
public function handleUpdatePlayerGameType(UpdatePlayerGameTypePacket $packet) : bool;
public function handleEmoteList(EmoteListPacket $packet) : bool;
public function handlePositionTrackingDBServerBroadcast(PositionTrackingDBServerBroadcastPacket $packet) : bool;
public function handlePositionTrackingDBClientRequest(PositionTrackingDBClientRequestPacket $packet) : bool;
public function handleDebugInfo(DebugInfoPacket $packet) : bool;
public function handlePacketViolationWarning(PacketViolationWarningPacket $packet) : bool;
public function handleMotionPredictionHints(MotionPredictionHintsPacket $packet) : bool;
public function handleAnimateEntity(AnimateEntityPacket $packet) : bool;
public function handleCameraShake(CameraShakePacket $packet) : bool;
public function handlePlayerFog(PlayerFogPacket $packet) : bool;
public function handleCorrectPlayerMovePrediction(CorrectPlayerMovePredictionPacket $packet) : bool;
public function handleItemComponent(ItemComponentPacket $packet) : bool;
public function handleFilterText(FilterTextPacket $packet) : bool;
public function handleClientboundDebugRenderer(ClientboundDebugRendererPacket $packet) : bool;
public function handleSyncActorProperty(SyncActorPropertyPacket $packet) : bool;
public function handleAddVolumeEntity(AddVolumeEntityPacket $packet) : bool;
public function handleRemoveVolumeEntity(RemoveVolumeEntityPacket $packet) : bool;
public function handleSimulationType(SimulationTypePacket $packet) : bool;
public function handleNpcDialogue(NpcDialoguePacket $packet) : bool;
}

View File

@ -1,227 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\utils\Binary;
use pocketmine\utils\BinaryDataException;
class PacketPool{
/** @var self|null */
protected static $instance = null;
public static function getInstance() : self{
if(self::$instance === null){
self::$instance = new self;
}
return self::$instance;
}
/** @var \SplFixedArray<Packet> */
protected $pool;
public function __construct(){
$this->pool = new \SplFixedArray(256);
$this->registerPacket(new LoginPacket());
$this->registerPacket(new PlayStatusPacket());
$this->registerPacket(new ServerToClientHandshakePacket());
$this->registerPacket(new ClientToServerHandshakePacket());
$this->registerPacket(new DisconnectPacket());
$this->registerPacket(new ResourcePacksInfoPacket());
$this->registerPacket(new ResourcePackStackPacket());
$this->registerPacket(new ResourcePackClientResponsePacket());
$this->registerPacket(new TextPacket());
$this->registerPacket(new SetTimePacket());
$this->registerPacket(new StartGamePacket());
$this->registerPacket(new AddPlayerPacket());
$this->registerPacket(new AddActorPacket());
$this->registerPacket(new RemoveActorPacket());
$this->registerPacket(new AddItemActorPacket());
$this->registerPacket(new TakeItemActorPacket());
$this->registerPacket(new MoveActorAbsolutePacket());
$this->registerPacket(new MovePlayerPacket());
$this->registerPacket(new RiderJumpPacket());
$this->registerPacket(new UpdateBlockPacket());
$this->registerPacket(new AddPaintingPacket());
$this->registerPacket(new TickSyncPacket());
$this->registerPacket(new LevelSoundEventPacketV1());
$this->registerPacket(new LevelEventPacket());
$this->registerPacket(new BlockEventPacket());
$this->registerPacket(new ActorEventPacket());
$this->registerPacket(new MobEffectPacket());
$this->registerPacket(new UpdateAttributesPacket());
$this->registerPacket(new InventoryTransactionPacket());
$this->registerPacket(new MobEquipmentPacket());
$this->registerPacket(new MobArmorEquipmentPacket());
$this->registerPacket(new InteractPacket());
$this->registerPacket(new BlockPickRequestPacket());
$this->registerPacket(new ActorPickRequestPacket());
$this->registerPacket(new PlayerActionPacket());
$this->registerPacket(new HurtArmorPacket());
$this->registerPacket(new SetActorDataPacket());
$this->registerPacket(new SetActorMotionPacket());
$this->registerPacket(new SetActorLinkPacket());
$this->registerPacket(new SetHealthPacket());
$this->registerPacket(new SetSpawnPositionPacket());
$this->registerPacket(new AnimatePacket());
$this->registerPacket(new RespawnPacket());
$this->registerPacket(new ContainerOpenPacket());
$this->registerPacket(new ContainerClosePacket());
$this->registerPacket(new PlayerHotbarPacket());
$this->registerPacket(new InventoryContentPacket());
$this->registerPacket(new InventorySlotPacket());
$this->registerPacket(new ContainerSetDataPacket());
$this->registerPacket(new CraftingDataPacket());
$this->registerPacket(new CraftingEventPacket());
$this->registerPacket(new GuiDataPickItemPacket());
$this->registerPacket(new AdventureSettingsPacket());
$this->registerPacket(new BlockActorDataPacket());
$this->registerPacket(new PlayerInputPacket());
$this->registerPacket(new LevelChunkPacket());
$this->registerPacket(new SetCommandsEnabledPacket());
$this->registerPacket(new SetDifficultyPacket());
$this->registerPacket(new ChangeDimensionPacket());
$this->registerPacket(new SetPlayerGameTypePacket());
$this->registerPacket(new PlayerListPacket());
$this->registerPacket(new SimpleEventPacket());
$this->registerPacket(new EventPacket());
$this->registerPacket(new SpawnExperienceOrbPacket());
$this->registerPacket(new ClientboundMapItemDataPacket());
$this->registerPacket(new MapInfoRequestPacket());
$this->registerPacket(new RequestChunkRadiusPacket());
$this->registerPacket(new ChunkRadiusUpdatedPacket());
$this->registerPacket(new ItemFrameDropItemPacket());
$this->registerPacket(new GameRulesChangedPacket());
$this->registerPacket(new CameraPacket());
$this->registerPacket(new BossEventPacket());
$this->registerPacket(new ShowCreditsPacket());
$this->registerPacket(new AvailableCommandsPacket());
$this->registerPacket(new CommandRequestPacket());
$this->registerPacket(new CommandBlockUpdatePacket());
$this->registerPacket(new CommandOutputPacket());
$this->registerPacket(new UpdateTradePacket());
$this->registerPacket(new UpdateEquipPacket());
$this->registerPacket(new ResourcePackDataInfoPacket());
$this->registerPacket(new ResourcePackChunkDataPacket());
$this->registerPacket(new ResourcePackChunkRequestPacket());
$this->registerPacket(new TransferPacket());
$this->registerPacket(new PlaySoundPacket());
$this->registerPacket(new StopSoundPacket());
$this->registerPacket(new SetTitlePacket());
$this->registerPacket(new AddBehaviorTreePacket());
$this->registerPacket(new StructureBlockUpdatePacket());
$this->registerPacket(new ShowStoreOfferPacket());
$this->registerPacket(new PurchaseReceiptPacket());
$this->registerPacket(new PlayerSkinPacket());
$this->registerPacket(new SubClientLoginPacket());
$this->registerPacket(new AutomationClientConnectPacket());
$this->registerPacket(new SetLastHurtByPacket());
$this->registerPacket(new BookEditPacket());
$this->registerPacket(new NpcRequestPacket());
$this->registerPacket(new PhotoTransferPacket());
$this->registerPacket(new ModalFormRequestPacket());
$this->registerPacket(new ModalFormResponsePacket());
$this->registerPacket(new ServerSettingsRequestPacket());
$this->registerPacket(new ServerSettingsResponsePacket());
$this->registerPacket(new ShowProfilePacket());
$this->registerPacket(new SetDefaultGameTypePacket());
$this->registerPacket(new RemoveObjectivePacket());
$this->registerPacket(new SetDisplayObjectivePacket());
$this->registerPacket(new SetScorePacket());
$this->registerPacket(new LabTablePacket());
$this->registerPacket(new UpdateBlockSyncedPacket());
$this->registerPacket(new MoveActorDeltaPacket());
$this->registerPacket(new SetScoreboardIdentityPacket());
$this->registerPacket(new SetLocalPlayerAsInitializedPacket());
$this->registerPacket(new UpdateSoftEnumPacket());
$this->registerPacket(new NetworkStackLatencyPacket());
$this->registerPacket(new ScriptCustomEventPacket());
$this->registerPacket(new SpawnParticleEffectPacket());
$this->registerPacket(new AvailableActorIdentifiersPacket());
$this->registerPacket(new LevelSoundEventPacketV2());
$this->registerPacket(new NetworkChunkPublisherUpdatePacket());
$this->registerPacket(new BiomeDefinitionListPacket());
$this->registerPacket(new LevelSoundEventPacket());
$this->registerPacket(new LevelEventGenericPacket());
$this->registerPacket(new LecternUpdatePacket());
$this->registerPacket(new AddEntityPacket());
$this->registerPacket(new RemoveEntityPacket());
$this->registerPacket(new ClientCacheStatusPacket());
$this->registerPacket(new OnScreenTextureAnimationPacket());
$this->registerPacket(new MapCreateLockedCopyPacket());
$this->registerPacket(new StructureTemplateDataRequestPacket());
$this->registerPacket(new StructureTemplateDataResponsePacket());
$this->registerPacket(new ClientCacheBlobStatusPacket());
$this->registerPacket(new ClientCacheMissResponsePacket());
$this->registerPacket(new EducationSettingsPacket());
$this->registerPacket(new EmotePacket());
$this->registerPacket(new MultiplayerSettingsPacket());
$this->registerPacket(new SettingsCommandPacket());
$this->registerPacket(new AnvilDamagePacket());
$this->registerPacket(new CompletedUsingItemPacket());
$this->registerPacket(new NetworkSettingsPacket());
$this->registerPacket(new PlayerAuthInputPacket());
$this->registerPacket(new CreativeContentPacket());
$this->registerPacket(new PlayerEnchantOptionsPacket());
$this->registerPacket(new ItemStackRequestPacket());
$this->registerPacket(new ItemStackResponsePacket());
$this->registerPacket(new PlayerArmorDamagePacket());
$this->registerPacket(new CodeBuilderPacket());
$this->registerPacket(new UpdatePlayerGameTypePacket());
$this->registerPacket(new EmoteListPacket());
$this->registerPacket(new PositionTrackingDBServerBroadcastPacket());
$this->registerPacket(new PositionTrackingDBClientRequestPacket());
$this->registerPacket(new DebugInfoPacket());
$this->registerPacket(new PacketViolationWarningPacket());
$this->registerPacket(new MotionPredictionHintsPacket());
$this->registerPacket(new AnimateEntityPacket());
$this->registerPacket(new CameraShakePacket());
$this->registerPacket(new PlayerFogPacket());
$this->registerPacket(new CorrectPlayerMovePredictionPacket());
$this->registerPacket(new ItemComponentPacket());
$this->registerPacket(new FilterTextPacket());
$this->registerPacket(new ClientboundDebugRendererPacket());
$this->registerPacket(new SyncActorPropertyPacket());
$this->registerPacket(new AddVolumeEntityPacket());
$this->registerPacket(new RemoveVolumeEntityPacket());
$this->registerPacket(new SimulationTypePacket());
$this->registerPacket(new NpcDialoguePacket());
}
public function registerPacket(Packet $packet) : void{
$this->pool[$packet->pid()] = clone $packet;
}
public function getPacketById(int $pid) : Packet{
return isset($this->pool[$pid]) ? clone $this->pool[$pid] : new UnknownPacket();
}
/**
* @throws BinaryDataException
*/
public function getPacket(string $buffer) : Packet{
$offset = 0;
return $this->getPacketById(Binary::readUnsignedVarInt($buffer, $offset) & DataPacket::PID_MASK);
}
}

View File

@ -1,84 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class PacketViolationWarningPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::PACKET_VIOLATION_WARNING_PACKET;
public const TYPE_MALFORMED = 0;
public const SEVERITY_WARNING = 0;
public const SEVERITY_FINAL_WARNING = 1;
public const SEVERITY_TERMINATING_CONNECTION = 2;
/** @var int */
private $type;
/** @var int */
private $severity;
/** @var int */
private $packetId;
/** @var string */
private $message;
public static function create(int $type, int $severity, int $packetId, string $message) : self{
$result = new self;
$result->type = $type;
$result->severity = $severity;
$result->packetId = $packetId;
$result->message = $message;
return $result;
}
public function getType() : int{ return $this->type; }
public function getSeverity() : int{ return $this->severity; }
public function getPacketId() : int{ return $this->packetId; }
public function getMessage() : string{ return $this->message; }
protected function decodePayload(PacketSerializer $in) : void{
$this->type = $in->getVarInt();
$this->severity = $in->getVarInt();
$this->packetId = $in->getVarInt();
$this->message = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->type);
$out->putVarInt($this->severity);
$out->putVarInt($this->packetId);
$out->putString($this->message);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePacketViolationWarning($this);
}
}

View File

@ -1,55 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
/** @var string */
public $photoName;
/** @var string */
public $photoData;
/** @var string */
public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
protected function decodePayload(PacketSerializer $in) : void{
$this->photoName = $in->getString();
$this->photoData = $in->getString();
$this->bookId = $in->getString();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->photoName);
$out->putString($this->photoData);
$out->putString($this->bookId);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePhotoTransfer($this);
}
}

View File

@ -1,66 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
class PlaySoundPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
/** @var string */
public $soundName;
/** @var float */
public $x;
/** @var float */
public $y;
/** @var float */
public $z;
/** @var float */
public $volume;
/** @var float */
public $pitch;
protected function decodePayload(PacketSerializer $in) : void{
$this->soundName = $in->getString();
$in->getBlockPosition($this->x, $this->y, $this->z);
$this->x /= 8;
$this->y /= 8;
$this->z /= 8;
$this->volume = $in->getLFloat();
$this->pitch = $in->getLFloat();
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->soundName);
$out->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
$out->putLFloat($this->volume);
$out->putLFloat($this->pitch);
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePlaySound($this);
}
}

Some files were not shown because too many files have changed in this diff Show More