mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Merge branch 'api3/network_mcpe-1.0.5' into api3/network
This commit is contained in:
@ -34,10 +34,12 @@ use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandStepPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
|
||||
@ -69,6 +71,7 @@ use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
@ -92,9 +95,11 @@ use pocketmine\network\mcpe\protocol\SetHealthPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTimePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
@ -180,6 +185,8 @@ interface NetworkSession{
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool;
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool;
|
||||
|
||||
public function handleUseItem(UseItemPacket $packet) : bool;
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool;
|
||||
@ -268,6 +275,8 @@ interface NetworkSession{
|
||||
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool;
|
||||
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool;
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool;
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool;
|
||||
@ -278,5 +287,11 @@ interface NetworkSession{
|
||||
|
||||
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 handleUnknown(UnknownPacket $packet) : bool;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BlockPickRequestPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
|
||||
|
||||
public $tileX;
|
||||
public $tileY;
|
||||
public $tileZ;
|
||||
public $hotbarSlot;
|
||||
|
||||
public function decode(){
|
||||
$this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockPickRequest($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CommandBlockUpdatePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
|
||||
|
||||
public $isBlock;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $commandBlockMode;
|
||||
public $isRedstoneMode;
|
||||
public $isConditional;
|
||||
|
||||
public $minecartEid;
|
||||
|
||||
public $command;
|
||||
public $lastOutput;
|
||||
public $name;
|
||||
|
||||
public $shouldTrackOutput;
|
||||
|
||||
public function decode(){
|
||||
$this->isBlock = $this->getBool();
|
||||
|
||||
if($this->isBlock){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->commandBlockMode = $this->getUnsignedVarInt();
|
||||
$this->isRedstoneMode = $this->getBool();
|
||||
$this->isConditional = $this->getBool();
|
||||
}else{
|
||||
//Minecart with command block
|
||||
$this->minecartEid = $this->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
$this->command = $this->getString();
|
||||
$this->lastOutput = $this->getString();
|
||||
$this->name = $this->getString();
|
||||
|
||||
$this->shouldTrackOutput = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putBool($this->isBlock);
|
||||
|
||||
if($this->isBlock){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->commandBlockMode);
|
||||
$this->putBool($this->isRedstoneMode);
|
||||
$this->putBool($this->isConditional);
|
||||
}else{
|
||||
$this->putEntityRuntimeId($this->minecartEid);
|
||||
}
|
||||
|
||||
$this->putString($this->command);
|
||||
$this->putString($this->lastOutput);
|
||||
$this->putString($this->name);
|
||||
|
||||
$this->putBool($this->shouldTrackOutput);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCommandBlockUpdate($this);
|
||||
}
|
||||
}
|
@ -120,17 +120,15 @@ abstract class DataPacket extends BinaryStream{
|
||||
$value[2] = $item->getDamage();
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
$value = [];
|
||||
$value[0] = $this->getVarInt(); //x
|
||||
$value[1] = $this->getVarInt(); //y (SIGNED)
|
||||
$value[2] = $this->getVarInt(); //z
|
||||
$value = [0, 0, 0];
|
||||
$this->getSignedBlockPosition(...$value);
|
||||
break;
|
||||
case Entity::DATA_TYPE_LONG:
|
||||
$value = $this->getVarLong();
|
||||
break;
|
||||
case Entity::DATA_TYPE_VECTOR3F:
|
||||
$value = [0.0, 0.0, 0.0];
|
||||
$this->getVector3f($value[0], $value[1], $value[2]);
|
||||
$this->getVector3f(...$value);
|
||||
break;
|
||||
default:
|
||||
$value = [];
|
||||
@ -177,16 +175,14 @@ abstract class DataPacket extends BinaryStream{
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
//TODO: change this implementation (use objects)
|
||||
$this->putVarInt($d[1][0]); //x
|
||||
$this->putVarInt($d[1][1]); //y (SIGNED)
|
||||
$this->putVarInt($d[1][2]); //z
|
||||
$this->putSignedBlockPosition(...$d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_LONG:
|
||||
$this->putVarLong($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_VECTOR3F:
|
||||
//TODO: change this implementation (use objects)
|
||||
$this->putVector3f($d[1][0], $d[1][1], $d[1][2]); //x, y, z
|
||||
$this->putVector3f(...$d[1]); //x, y, z
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,7 +220,7 @@ abstract class DataPacket extends BinaryStream{
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an block position with unsigned Y coordinate.
|
||||
* Reads an block position with unsigned Y coordinate.
|
||||
* @param int $x
|
||||
* @param int $y 0-255
|
||||
* @param int $z
|
||||
@ -236,7 +232,7 @@ abstract class DataPacket extends BinaryStream{
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a block position with unsigned Y coordinate.
|
||||
* Writes a block position with unsigned Y coordinate.
|
||||
* @param int &$x
|
||||
* @param int &$y
|
||||
* @param int &$z
|
||||
@ -247,6 +243,30 @@ abstract class DataPacket extends BinaryStream{
|
||||
$this->putVarInt($z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a block position with a signed Y coordinate.
|
||||
* @param int &$x
|
||||
* @param int &$y
|
||||
* @param int &$z
|
||||
*/
|
||||
public function getSignedBlockPosition(&$x, &$y, &$z){
|
||||
$x = $this->getVarInt();
|
||||
$y = $this->getVarInt();
|
||||
$z = $this->getVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a block position with a signed Y coordinate.
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*/
|
||||
public function putSignedBlockPosition($x, $y, $z){
|
||||
$this->putVarInt($x);
|
||||
$this->putVarInt($y);
|
||||
$this->putVarInt($z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a floating-point vector3 rounded to 4dp.
|
||||
* @param float $x
|
||||
|
@ -43,9 +43,10 @@ class EntityEventPacket extends DataPacket{
|
||||
const FISH_HOOK_TEASE = 14;
|
||||
const SQUID_INK_CLOUD = 15;
|
||||
const AMBIENT_SOUND = 16;
|
||||
const RESPAWN = 17;
|
||||
|
||||
//TODO add new events
|
||||
const RESPAWN = 18;
|
||||
|
||||
//TODO: add more events
|
||||
|
||||
public $eid;
|
||||
public $event;
|
||||
|
58
src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php
Normal file
58
src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PlaySoundPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
|
||||
|
||||
public $string1;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $float1;
|
||||
public $float2;
|
||||
|
||||
public function decode(){
|
||||
$this->string1 = $this->getString();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->float1 = $this->getLFloat();
|
||||
$this->float2 = $this->getLFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putString($this->string1);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->float1);
|
||||
$this->putLFloat($this->float2);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlaySound($this);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
* This file is generated automatically, do not edit it manually.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -30,9 +31,9 @@ interface ProtocolInfo{
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
const CURRENT_PROTOCOL = 102;
|
||||
const MINECRAFT_VERSION = "v1.0.4.11";
|
||||
const MINECRAFT_VERSION_NETWORK = "1.0.4.11";
|
||||
const CURRENT_PROTOCOL = 105;
|
||||
const MINECRAFT_VERSION = "v1.0.5.0 beta";
|
||||
const MINECRAFT_VERSION_NETWORK = "1.0.5.0";
|
||||
|
||||
const LOGIN_PACKET = 0x01;
|
||||
const PLAY_STATUS_PACKET = 0x02;
|
||||
@ -68,54 +69,59 @@ interface ProtocolInfo{
|
||||
const MOB_EQUIPMENT_PACKET = 0x20;
|
||||
const MOB_ARMOR_EQUIPMENT_PACKET = 0x21;
|
||||
const INTERACT_PACKET = 0x22;
|
||||
const USE_ITEM_PACKET = 0x23;
|
||||
const PLAYER_ACTION_PACKET = 0x24;
|
||||
const PLAYER_FALL_PACKET = 0x25;
|
||||
const HURT_ARMOR_PACKET = 0x26;
|
||||
const SET_ENTITY_DATA_PACKET = 0x27;
|
||||
const SET_ENTITY_MOTION_PACKET = 0x28;
|
||||
const SET_ENTITY_LINK_PACKET = 0x29;
|
||||
const SET_HEALTH_PACKET = 0x2a;
|
||||
const SET_SPAWN_POSITION_PACKET = 0x2b;
|
||||
const ANIMATE_PACKET = 0x2c;
|
||||
const RESPAWN_PACKET = 0x2d;
|
||||
const DROP_ITEM_PACKET = 0x2e;
|
||||
const INVENTORY_ACTION_PACKET = 0x2f;
|
||||
const CONTAINER_OPEN_PACKET = 0x30;
|
||||
const CONTAINER_CLOSE_PACKET = 0x31;
|
||||
const CONTAINER_SET_SLOT_PACKET = 0x32;
|
||||
const CONTAINER_SET_DATA_PACKET = 0x33;
|
||||
const CONTAINER_SET_CONTENT_PACKET = 0x34;
|
||||
const CRAFTING_DATA_PACKET = 0x35;
|
||||
const CRAFTING_EVENT_PACKET = 0x36;
|
||||
const ADVENTURE_SETTINGS_PACKET = 0x37;
|
||||
const BLOCK_ENTITY_DATA_PACKET = 0x38;
|
||||
const PLAYER_INPUT_PACKET = 0x39;
|
||||
const FULL_CHUNK_DATA_PACKET = 0x3a;
|
||||
const SET_COMMANDS_ENABLED_PACKET = 0x3b;
|
||||
const SET_DIFFICULTY_PACKET = 0x3c;
|
||||
const CHANGE_DIMENSION_PACKET = 0x3d;
|
||||
const SET_PLAYER_GAME_TYPE_PACKET = 0x3e;
|
||||
const PLAYER_LIST_PACKET = 0x3f;
|
||||
const EVENT_PACKET = 0x40; //TelemetryEventPacket
|
||||
const SPAWN_EXPERIENCE_ORB_PACKET = 0x41;
|
||||
const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0x42; //MapItemDataPacket
|
||||
const MAP_INFO_REQUEST_PACKET = 0x43;
|
||||
const REQUEST_CHUNK_RADIUS_PACKET = 0x44;
|
||||
const CHUNK_RADIUS_UPDATED_PACKET = 0x45;
|
||||
const ITEM_FRAME_DROP_ITEM_PACKET = 0x46;
|
||||
const REPLACE_ITEM_IN_SLOT_PACKET = 0x47; //ReplaceSelectedItemPacket
|
||||
const GAME_RULES_CHANGED_PACKET = 0x48;
|
||||
const CAMERA_PACKET = 0x49;
|
||||
const ADD_ITEM_PACKET = 0x4a;
|
||||
const BOSS_EVENT_PACKET = 0x4b;
|
||||
const SHOW_CREDITS_PACKET = 0x4c;
|
||||
const AVAILABLE_COMMANDS_PACKET = 0x4d;
|
||||
const COMMAND_STEP_PACKET = 0x4e;
|
||||
const UPDATE_TRADE_PACKET = 0x4f;
|
||||
const RESOURCE_PACK_DATA_INFO_PACKET = 0x50;
|
||||
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x51;
|
||||
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x52;
|
||||
const TRANSFER_PACKET = 0x53;
|
||||
const BLOCK_PICK_REQUEST_PACKET = 0x23;
|
||||
const USE_ITEM_PACKET = 0x24;
|
||||
const PLAYER_ACTION_PACKET = 0x25;
|
||||
const PLAYER_FALL_PACKET = 0x26;
|
||||
const HURT_ARMOR_PACKET = 0x27;
|
||||
const SET_ENTITY_DATA_PACKET = 0x28;
|
||||
const SET_ENTITY_MOTION_PACKET = 0x29;
|
||||
const SET_ENTITY_LINK_PACKET = 0x2a;
|
||||
const SET_HEALTH_PACKET = 0x2b;
|
||||
const SET_SPAWN_POSITION_PACKET = 0x2c;
|
||||
const ANIMATE_PACKET = 0x2d;
|
||||
const RESPAWN_PACKET = 0x2e;
|
||||
const DROP_ITEM_PACKET = 0x2f;
|
||||
const INVENTORY_ACTION_PACKET = 0x30;
|
||||
const CONTAINER_OPEN_PACKET = 0x31;
|
||||
const CONTAINER_CLOSE_PACKET = 0x32;
|
||||
const CONTAINER_SET_SLOT_PACKET = 0x33;
|
||||
const CONTAINER_SET_DATA_PACKET = 0x34;
|
||||
const CONTAINER_SET_CONTENT_PACKET = 0x35;
|
||||
const CRAFTING_DATA_PACKET = 0x36;
|
||||
const CRAFTING_EVENT_PACKET = 0x37;
|
||||
const ADVENTURE_SETTINGS_PACKET = 0x38;
|
||||
const BLOCK_ENTITY_DATA_PACKET = 0x39;
|
||||
const PLAYER_INPUT_PACKET = 0x3a;
|
||||
const FULL_CHUNK_DATA_PACKET = 0x3b;
|
||||
const SET_COMMANDS_ENABLED_PACKET = 0x3c;
|
||||
const SET_DIFFICULTY_PACKET = 0x3d;
|
||||
const CHANGE_DIMENSION_PACKET = 0x3e;
|
||||
const SET_PLAYER_GAME_TYPE_PACKET = 0x3f;
|
||||
const PLAYER_LIST_PACKET = 0x40;
|
||||
const EVENT_PACKET = 0x41; //TelemetryEventPacket
|
||||
const SPAWN_EXPERIENCE_ORB_PACKET = 0x42;
|
||||
const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0x43; //MapItemDataPacket
|
||||
const MAP_INFO_REQUEST_PACKET = 0x44;
|
||||
const REQUEST_CHUNK_RADIUS_PACKET = 0x45;
|
||||
const CHUNK_RADIUS_UPDATED_PACKET = 0x46;
|
||||
const ITEM_FRAME_DROP_ITEM_PACKET = 0x47;
|
||||
const REPLACE_ITEM_IN_SLOT_PACKET = 0x48; //ReplaceSelectedItemPacket
|
||||
const GAME_RULES_CHANGED_PACKET = 0x49;
|
||||
const CAMERA_PACKET = 0x4a;
|
||||
const ADD_ITEM_PACKET = 0x4b;
|
||||
const BOSS_EVENT_PACKET = 0x4c;
|
||||
const SHOW_CREDITS_PACKET = 0x4d;
|
||||
const AVAILABLE_COMMANDS_PACKET = 0x4e;
|
||||
const COMMAND_STEP_PACKET = 0x4f;
|
||||
const COMMAND_BLOCK_UPDATE_PACKET = 0x50;
|
||||
const UPDATE_TRADE_PACKET = 0x51;
|
||||
const RESOURCE_PACK_DATA_INFO_PACKET = 0x52;
|
||||
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x53;
|
||||
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x54;
|
||||
const TRANSFER_PACKET = 0x55;
|
||||
const PLAY_SOUND_PACKET = 0x56;
|
||||
const STOP_SOUND_PACKET = 0x57;
|
||||
const SET_TITLE_PACKET = 0x58;
|
||||
|
||||
}
|
||||
|
66
src/pocketmine/network/mcpe/protocol/SetTitlePacket.php
Normal file
66
src/pocketmine/network/mcpe/protocol/SetTitlePacket.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SetTitlePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SET_TITLE_PACKET;
|
||||
|
||||
const TYPE_CLEAR_TITLE = 0;
|
||||
const TYPE_RESET_TITLE = 1;
|
||||
const TYPE_SET_TITLE = 2;
|
||||
const TYPE_SET_SUBTITLE = 3;
|
||||
const TYPE_SET_ACTIONBAR_MESSAGE = 4;
|
||||
const TYPE_SET_ANIMATION_TIMES = 5;
|
||||
|
||||
public $type;
|
||||
public $text;
|
||||
public $fadeInTime;
|
||||
public $stayTime;
|
||||
public $fadeOutTime;
|
||||
|
||||
public function decode(){
|
||||
$this->type = $this->getVarInt();
|
||||
$this->text = $this->getString();
|
||||
$this->fadeInTime = $this->getVarInt();
|
||||
$this->stayTime = $this->getVarInt();
|
||||
$this->fadeOutTime = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVarInt($this->type);
|
||||
$this->putString($this->text);
|
||||
$this->putVarInt($this->fadeInTime);
|
||||
$this->putVarInt($this->stayTime);
|
||||
$this->putVarInt($this->fadeOutTime);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetTitle($this);
|
||||
}
|
||||
}
|
50
src/pocketmine/network/mcpe/protocol/StopSoundPacket.php
Normal file
50
src/pocketmine/network/mcpe/protocol/StopSoundPacket.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class StopSoundPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET;
|
||||
|
||||
public $string1;
|
||||
public $stopAll;
|
||||
|
||||
public function decode(){
|
||||
$this->string1 = $this->getString();
|
||||
$this->stopAll = $this->getBool();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putString($this->string1);
|
||||
$this->putBool($this->stopAll);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleStopSound($this);
|
||||
}
|
||||
}
|
@ -26,13 +26,14 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\WindowTypes;
|
||||
|
||||
class UpdateTradePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET;
|
||||
|
||||
//TODO: find fields
|
||||
public $byte1;
|
||||
public $byte2;
|
||||
public $windowId;
|
||||
public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_-
|
||||
public $varint1;
|
||||
public $varint2;
|
||||
public $isWilling;
|
||||
@ -42,8 +43,8 @@ class UpdateTradePacket extends DataPacket{
|
||||
public $offers;
|
||||
|
||||
public function decode(){
|
||||
$this->byte1 = $this->getByte();
|
||||
$this->byte2 = $this->getByte();
|
||||
$this->windowId = $this->getByte();
|
||||
$this->windowType = $this->getByte();
|
||||
$this->varint1 = $this->getVarInt();
|
||||
$this->varint2 = $this->getVarInt();
|
||||
$this->isWilling = $this->getBool();
|
||||
@ -55,8 +56,8 @@ class UpdateTradePacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->byte1);
|
||||
$this->putByte($this->byte2);
|
||||
$this->putByte($this->windowId);
|
||||
$this->putByte($this->windowType);
|
||||
$this->putVarInt($this->varint1);
|
||||
$this->putVarInt($this->varint2);
|
||||
$this->putBool($this->isWilling);
|
||||
|
@ -23,7 +23,7 @@
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
|
||||
interface InventoryNetworkIds{
|
||||
interface WindowTypes{
|
||||
|
||||
const INVENTORY = -1;
|
||||
const CONTAINER = 0;
|
||||
@ -39,4 +39,9 @@ interface InventoryNetworkIds{
|
||||
const MINECART_CHEST = 10;
|
||||
const MINECART_HOPPER = 11;
|
||||
const HORSE = 12;
|
||||
const BEACON = 13;
|
||||
const STRUCTURE_EDITOR = 14;
|
||||
const TRADING = 15;
|
||||
const COMMAND_BLOCK = 16;
|
||||
|
||||
}
|
Reference in New Issue
Block a user