mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Added new packets
This commit is contained in:
parent
0cd1e82c52
commit
eb13cec5d0
@ -77,6 +77,7 @@ use pocketmine\network\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\protocol\RespawnPacket;
|
||||
use pocketmine\network\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\protocol\SetEntityDataPacket;
|
||||
@ -353,6 +354,7 @@ class Network{
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET, ResourcePackClientResponsePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACKS_INFO_PACKET, ResourcePacksInfoPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RIDER_JUMP_PACKET, RiderJumpPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_COMMANDS_ENABLED_PACKET, SetCommandsEnabledPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_DATA_PACKET, SetEntityDataPacket::class);
|
||||
|
@ -31,6 +31,8 @@ class PlayStatusPacket extends DataPacket{
|
||||
const LOGIN_FAILED_CLIENT = 1;
|
||||
const LOGIN_FAILED_SERVER = 2;
|
||||
const PLAYER_SPAWN = 3;
|
||||
const LOGIN_FAILED_INVALID_TENANT = 4;
|
||||
const LOGIN_FAILED_EDITION_MISMATCH = 5;
|
||||
|
||||
public $status;
|
||||
|
||||
|
@ -27,6 +27,11 @@ namespace pocketmine\network\protocol;
|
||||
class ResourcePackClientResponsePacket extends DataPacket{
|
||||
const NETWORK_ID = Info::RESOURCE_PACK_CLIENT_RESPONSE_PACKET;
|
||||
|
||||
const STATUS_REFUSED = 1;
|
||||
const STATUS_SEND_PACKS = 2;
|
||||
const STATUS_HAVE_ALL_PACKS = 3;
|
||||
const STATUS_COMPLETED = 4;
|
||||
|
||||
public $status; //TODO: add constants for status types
|
||||
public $packIds = [];
|
||||
|
||||
|
73
src/pocketmine/network/protocol/ResourcePackStackPacket.php
Normal file
73
src/pocketmine/network/protocol/ResourcePackStackPacket.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\resourcepacks\ResourcePackInfoEntry;
|
||||
|
||||
class ResourcePackStackPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::RESOURCE_PACK_STACK_PACKET;
|
||||
|
||||
public $mustAccept = false;
|
||||
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $behaviorPackStack = [];
|
||||
/** @var ResourcePackInfoEntry[] */
|
||||
public $resourcePackStack = [];
|
||||
|
||||
public function decode(){
|
||||
$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getLShort();
|
||||
while($behaviorPackCountCount-- > 0){
|
||||
$packId = $this->getString();
|
||||
$version = $this->getString();
|
||||
$this->behaviorPackStack[] = new ResourcePackInfoEntry($packId, $version);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->getLShort();
|
||||
while($resourcePackCount-- > 0){
|
||||
$packId = $this->getString();
|
||||
$version = $this->getString();
|
||||
$this->resourcePackStack[] = new ResourcePackInfoEntry($packId, $version);
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBool($this->mustAccept);
|
||||
|
||||
$this->putLShort(count($this->behaviorPackStack));
|
||||
foreach($this->behaviorPackStack as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
}
|
||||
|
||||
$this->putLShort(count($this->resourcePackStack));
|
||||
foreach($this->resourcePackStack as $entry){
|
||||
$this->putString($entry->getPackId());
|
||||
$this->putString($entry->getVersion());
|
||||
}
|
||||
}
|
||||
}
|
@ -21,11 +21,11 @@
|
||||
|
||||
namespace pocketmine\network\protocol;
|
||||
|
||||
use pocketmine\resourcepacks\ResourcePackInfoEntry;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\resourcepacks\ResourcePackInfoEntry;
|
||||
|
||||
class ResourcePacksInfoPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::RESOURCE_PACKS_INFO_PACKET;
|
||||
|
||||
|
41
src/pocketmine/network/protocol/RiderJumpPacket.php
Normal file
41
src/pocketmine/network/protocol/RiderJumpPacket.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
class RiderJumpPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::RIDER_JUMP_PACKET;
|
||||
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ class ResourcePackInfoEntry{
|
||||
protected $version;
|
||||
protected $packSize;
|
||||
|
||||
public function __construct(string $packId, string $version, $packSize){
|
||||
public function __construct(string $packId, string $version, $packSize = 0){
|
||||
$this->packId = $packId;
|
||||
$this->version = $version;
|
||||
$this->packSize = $packSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user