mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Updated existing packets and added new ones
This commit is contained in:
parent
affed33066
commit
86ed0f1397
@ -1451,7 +1451,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if($this->chunk !== null){
|
||||
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ);
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->entities[] = [0, $mot->x, $mot->y, $mot->z];
|
||||
$pk->eid = 0;
|
||||
$pk->motionX = $mot->x;
|
||||
$pk->motionY = $mot->y;
|
||||
$pk->motionZ = $mot->z;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
|
||||
|
@ -723,9 +723,14 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
foreach($this->motionToSend as $index => $entry){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->entities = $entry;
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
foreach($entry as $entity){
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $entity[0];
|
||||
$pk->motionX = $entity[1];
|
||||
$pk->motionY = $entity[2];
|
||||
$pk->motionZ = $entity[3];
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
}
|
||||
$this->motionToSend = [];
|
||||
|
||||
|
@ -25,7 +25,9 @@
|
||||
namespace pocketmine\network;
|
||||
|
||||
use pocketmine\network\protocol\AddEntityPacket;
|
||||
use pocketmine\network\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\protocol\AddItemPacket;
|
||||
use pocketmine\network\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\protocol\AdventureSettingsPacket;
|
||||
@ -52,19 +54,25 @@ use pocketmine\network\protocol\HurtArmorPacket;
|
||||
use pocketmine\network\protocol\Info as ProtocolInfo;
|
||||
use pocketmine\network\protocol\Info;
|
||||
use pocketmine\network\protocol\InteractPacket;
|
||||
use pocketmine\network\protocol\InventoryActionPacket;
|
||||
use pocketmine\network\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\protocol\LevelEventPacket;
|
||||
use pocketmine\network\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\protocol\LoginPacket;
|
||||
use pocketmine\network\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\protocol\PlayerListPacket;
|
||||
use pocketmine\network\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\protocol\ReplaceSelectedItemPacket;
|
||||
use pocketmine\network\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\protocol\RespawnPacket;
|
||||
use pocketmine\network\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\protocol\SetEntityLinkPacket;
|
||||
@ -73,6 +81,7 @@ use pocketmine\network\protocol\SetHealthPacket;
|
||||
use pocketmine\network\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\network\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\protocol\StartGamePacket;
|
||||
use pocketmine\network\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\protocol\TextPacket;
|
||||
@ -230,6 +239,7 @@ class Network{
|
||||
$pk->setBuffer($buf, 1);
|
||||
|
||||
$pk->decode();
|
||||
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread in " . get_class($pk));
|
||||
$p->handleDataPacket($pk);
|
||||
}
|
||||
}
|
||||
@ -283,56 +293,65 @@ class Network{
|
||||
private function registerPackets(){
|
||||
$this->packetPool = new \SplFixedArray(256);
|
||||
|
||||
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAY_STATUS_PACKET, PlayStatusPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BATCH_PACKET, BatchPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_PLAYER_PACKET, AddPlayerPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_ENTITY_PACKET, AddEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REMOVE_ENTITY_PACKET, RemoveEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_HANGING_ENTITY_PACKET, AddHangingEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOVE_ENTITY_PACKET, MoveEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOVE_PLAYER_PACKET, MovePlayerPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REMOVE_BLOCK_PACKET, RemoveBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_ITEM_PACKET, AddItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_PAINTING_PACKET, AddPaintingPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::LEVEL_EVENT_PACKET, LevelEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_EQUIPMENT_PACKET, MobEquipmentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::INTERACT_PACKET, InteractPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAYER_ACTION_PACKET, PlayerActionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::HURT_ARMOR_PACKET, HurtArmorPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_DATA_PACKET, SetEntityDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_LINK_PACKET, SetEntityLinkPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_HEALTH_PACKET, SetHealthPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_PLAYER_PACKET, AddPlayerPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ANIMATE_PACKET, AnimatePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, ContainerOpenPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BATCH_PACKET, BatchPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, ContainerClosePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_SET_SLOT_PACKET, ContainerSetSlotPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, ContainerOpenPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, ContainerSetContentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_SET_SLOT_PACKET, ContainerSetSlotPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CRAFTING_DATA_PACKET, CraftingDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CRAFTING_EVENT_PACKET, CraftingEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::HURT_ARMOR_PACKET, HurtArmorPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::INTERACT_PACKET, InteractPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::INVENTORY_ACTION_PACKET, InventoryActionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET, ItemFrameDropItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::LEVEL_EVENT_PACKET, LevelEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::LEVEL_SOUND_EVENT_PACKET, LevelSoundEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_EQUIPMENT_PACKET, MobEquipmentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOVE_ENTITY_PACKET, MoveEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOVE_PLAYER_PACKET, MovePlayerPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAYER_ACTION_PACKET, PlayerActionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAYER_INPUT_PACKET, PlayerInputPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::PLAY_STATUS_PACKET, PlayStatusPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REMOVE_BLOCK_PACKET, RemoveBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REMOVE_ENTITY_PACKET, RemoveEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REPLACE_SELECTED_ITEM_PACKET, ReplaceSelectedItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::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);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_LINK_PACKET, SetEntityLinkPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_HEALTH_PACKET, SetHealthPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET, SpawnExperienceOrbPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$pk = $this->getPacket($packet->buffer);
|
||||
if($pk !== null){
|
||||
$pk->decode();
|
||||
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread!");
|
||||
$this->players[$identifier]->handleDataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
@ -51,23 +51,20 @@ class AddEntityPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putInt($this->type);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->speedX);
|
||||
$this->putFloat($this->speedY);
|
||||
$this->putFloat($this->speedZ);
|
||||
$this->putFloat($this->yaw * (256 / 360));
|
||||
$this->putFloat($this->pitch * (256 / 360));
|
||||
$this->putInt($this->modifiers);
|
||||
$this->putEntityId($this->eid); //EntityUniqueID - TODO: verify this
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putUnsignedVarInt($this->type);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->putLFloat($this->yaw * (256 / 360));
|
||||
$this->putLFloat($this->pitch * (256 / 360));
|
||||
$this->putUnsignedVarInt($this->modifiers); //attributes?
|
||||
$meta = Binary::writeMetadata($this->metadata);
|
||||
$this->put($meta);
|
||||
$this->putShort(count($this->links));
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putLong($link[0]);
|
||||
$this->putLong($link[1]);
|
||||
$this->putEntityId($link[0]);
|
||||
$this->putEntityId($link[1]);
|
||||
$this->putByte($link[2]);
|
||||
}
|
||||
}
|
||||
|
48
src/pocketmine/network/protocol/AddHangingEntityPacket.php
Normal file
48
src/pocketmine/network/protocol/AddHangingEntityPacket.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
class AddHangingEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::ADD_HANGING_ENTITY_PACKET;
|
||||
|
||||
public $entityUniqueId;
|
||||
public $entityRuntimeId;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityId($this->entityUniqueId);
|
||||
$this->putEntityId($this->entityRuntimeId);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
}
|
@ -42,14 +42,11 @@ class AddItemEntityPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putSlot($this->item);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->speedX);
|
||||
$this->putFloat($this->speedY);
|
||||
$this->putFloat($this->speedZ);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
41
src/pocketmine/network/protocol/AddItemPacket.php
Normal file
41
src/pocketmine/network/protocol/AddItemPacket.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 AddItemPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::ADD_ITEM_PACKET;
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
}
|
@ -40,11 +40,10 @@ class AddPaintingPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putInt($this->direction);
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->direction);
|
||||
$this->putString($this->title);
|
||||
}
|
||||
|
||||
|
@ -53,16 +53,14 @@ class AddPlayerPacket extends DataPacket{
|
||||
$this->reset();
|
||||
$this->putUUID($this->uuid);
|
||||
$this->putString($this->username);
|
||||
$this->putLong($this->eid);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->speedX);
|
||||
$this->putFloat($this->speedY);
|
||||
$this->putFloat($this->speedZ);
|
||||
$this->putFloat($this->yaw);
|
||||
$this->putFloat($this->yaw); //TODO headrot
|
||||
$this->putFloat($this->pitch);
|
||||
$this->putEntityId($this->eid); //EntityUniqueID
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
//TODO: check these are in the right order
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->yaw); //TODO headrot
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putSlot($this->item);
|
||||
|
||||
$meta = Binary::writeMetadata($this->metadata);
|
||||
|
@ -32,13 +32,13 @@ class AnimatePacket extends DataPacket{
|
||||
|
||||
public function decode(){
|
||||
$this->action = $this->getByte();
|
||||
$this->eid = $this->getLong();
|
||||
$this->eid = $this->getEntityId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->action);
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,17 +33,13 @@ class BlockEntityDataPacket extends DataPacket{
|
||||
public $namedtag;
|
||||
|
||||
public function decode(){
|
||||
$this->x = $this->getInt();
|
||||
$this->y = $this->getInt();
|
||||
$this->z = $this->getInt();
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->get(true);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->put($this->namedtag);
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,9 @@ class BlockEventPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putInt($this->case1);
|
||||
$this->putInt($this->case2);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->case1);
|
||||
$this->putVarInt($this->case2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ChangeDimensionPacket extends DataPacket{
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknown;
|
||||
public $unknown; //bool
|
||||
|
||||
public function decode(){
|
||||
|
||||
@ -42,10 +42,8 @@ class ChangeDimensionPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->dimension);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putByte($this->unknown);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class ContainerOpenPacket extends DataPacket{
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $entityId = -1;
|
||||
|
||||
public function decode(){
|
||||
|
||||
@ -42,10 +43,9 @@ class ContainerOpenPacket extends DataPacket{
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putByte($this->type);
|
||||
$this->putShort($this->slots);
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putVarInt($this->slots);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putEntityId($this->entityId);
|
||||
}
|
||||
|
||||
}
|
@ -38,8 +38,8 @@ class ContainerSetDataPacket extends DataPacket{
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->windowid);
|
||||
$this->putShort($this->property);
|
||||
$this->putShort($this->value);
|
||||
$this->putVarInt($this->property);
|
||||
$this->putVarInt($this->value);
|
||||
}
|
||||
|
||||
}
|
@ -47,16 +47,19 @@ class EntityEventPacket extends DataPacket{
|
||||
|
||||
public $eid;
|
||||
public $event;
|
||||
public $unknown;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->event = $this->getByte();
|
||||
$this->unknown = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putByte($this->event);
|
||||
$this->putVarInt($this->unknown);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,16 +44,12 @@ class ExplodePacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putFloat($this->radius);
|
||||
$this->putInt(count($this->records));
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putLFloat($this->radius);
|
||||
$this->putUnsignedVarInt(count($this->records));
|
||||
if(count($this->records) > 0){
|
||||
foreach($this->records as $record){
|
||||
$this->putByte($record->x);
|
||||
$this->putByte($record->y);
|
||||
$this->putByte($record->z);
|
||||
$this->putBlockCoords($record->x, $record->y, $record->z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class HurtArmorPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->health);
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
}
|
@ -39,13 +39,13 @@ class InteractPacket extends DataPacket{
|
||||
|
||||
public function decode(){
|
||||
$this->action = $this->getByte();
|
||||
$this->target = $this->getLong();
|
||||
$this->target = $this->getEntityId();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->action);
|
||||
$this->putLong($this->target);
|
||||
$this->putEntityId($this->target);
|
||||
}
|
||||
|
||||
}
|
||||
|
40
src/pocketmine/network/protocol/InventoryActionPacket.php
Normal file
40
src/pocketmine/network/protocol/InventoryActionPacket.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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 InventoryActionPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::INVENTORY_ACTION_PACKET;
|
||||
|
||||
public $unknown;
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->putUnsignedVarInt($this->unknown);
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
}
|
44
src/pocketmine/network/protocol/ItemFrameDropItemPacket.php
Normal file
44
src/pocketmine/network/protocol/ItemFrameDropItemPacket.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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 ItemFrameDropItemPacket extends DataPacket{
|
||||
|
||||
const NETWORK_ID = Info::ITEM_FRAME_DROP_ITEM_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,6 @@ namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
class LevelEventPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::LEVEL_EVENT_PACKET;
|
||||
|
||||
@ -67,9 +66,9 @@ class LevelEventPacket extends DataPacket{
|
||||
const EVENT_ADD_PARTICLE_MASK = 0x4000;
|
||||
|
||||
public $evid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $x = 0; //Weather effects don't have coordinates
|
||||
public $y = 0;
|
||||
public $z = 0;
|
||||
public $data;
|
||||
|
||||
public function decode(){
|
||||
@ -78,11 +77,9 @@ class LevelEventPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putShort($this->evid);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putInt($this->data);
|
||||
$this->putVarInt($this->evid);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
|
50
src/pocketmine/network/protocol/LevelSoundEventPacket.php
Normal file
50
src/pocketmine/network/protocol/LevelSoundEventPacket.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\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
class LevelSoundEventPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::LEVEL_SOUND_EVENT_PACKET;
|
||||
|
||||
//TODO: find unknowns
|
||||
public $unknownByte;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $unknownVarInt1;
|
||||
public $unknownVarInt2;
|
||||
public $unknownBool;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->unknownByte);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->unknownVarInt1);
|
||||
$this->putVarInt($this->unknownVarInt2);
|
||||
$this->putByte($this->unknownBool);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
public $slots = [];
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->slots[0] = $this->getSlot();
|
||||
$this->slots[1] = $this->getSlot();
|
||||
$this->slots[2] = $this->getSlot();
|
||||
@ -40,7 +40,7 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putSlot($this->slots[0]);
|
||||
$this->putSlot($this->slots[1]);
|
||||
$this->putSlot($this->slots[2]);
|
||||
|
@ -44,12 +44,12 @@ class MobEffectPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putByte($this->eventId);
|
||||
$this->putByte($this->effectId);
|
||||
$this->putByte($this->amplifier);
|
||||
$this->putByte($this->particles ? 1 : 0);
|
||||
$this->putInt($this->duration);
|
||||
$this->putVarInt($this->effectId);
|
||||
$this->putVarInt($this->amplifier);
|
||||
$this->putByte($this->particles);
|
||||
$this->putVarInt($this->duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,20 +31,23 @@ class MobEquipmentPacket extends DataPacket{
|
||||
public $item;
|
||||
public $slot;
|
||||
public $selectedSlot;
|
||||
public $unknownByte;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->eid = $this->getEntityId(); //EntityRuntimeID
|
||||
$this->item = $this->getSlot();
|
||||
$this->slot = $this->getByte();
|
||||
$this->selectedSlot = $this->getByte();
|
||||
$this->unknownByte = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid); //EntityRuntimeID
|
||||
$this->putSlot($this->item);
|
||||
$this->putByte($this->slot);
|
||||
$this->putByte($this->selectedSlot);
|
||||
$this->putByte($this->unknownByte);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,10 +36,8 @@ class MoveEntityPacket extends DataPacket{
|
||||
public $pitch;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->x = $this->getFloat();
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->getVector3f($this->x, $this->y, $this->z);
|
||||
$this->pitch = $this->getByte() * (360.0 / 256);
|
||||
$this->yaw = $this->getByte() * (360.0 / 256);
|
||||
$this->headYaw = $this->getByte() * (360.0 / 256);
|
||||
@ -47,10 +45,8 @@ class MoveEntityPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putByte($this->pitch / (360.0 / 256));
|
||||
$this->putByte($this->yaw / (360.0 / 256));
|
||||
$this->putByte($this->headYaw / (360.0 / 256));
|
||||
|
@ -40,7 +40,7 @@ class PlayerActionPacket extends DataPacket{
|
||||
const ACTION_STOP_SPRINT = 10;
|
||||
const ACTION_START_SNEAK = 11;
|
||||
const ACTION_STOP_SNEAK = 12;
|
||||
const ACTION_DIMENSION_CHANGE = 13;
|
||||
const ACTION_DIMENSION_CHANGE = 13; //TODO: correct these
|
||||
|
||||
public $eid;
|
||||
public $action;
|
||||
@ -50,22 +50,18 @@ class PlayerActionPacket extends DataPacket{
|
||||
public $face;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->action = $this->getInt();
|
||||
$this->x = $this->getInt();
|
||||
$this->y = $this->getInt();
|
||||
$this->z = $this->getInt();
|
||||
$this->face = $this->getInt();
|
||||
$this->eid = $this->getEntityId();
|
||||
$this->action = $this->getVarInt();
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->face = $this->getVarInt();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putInt($this->action);
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putInt($this->face);
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVarInt($this->action);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->face);
|
||||
}
|
||||
|
||||
}
|
||||
|
46
src/pocketmine/network/protocol/PlayerInputPacket.php
Normal file
46
src/pocketmine/network/protocol/PlayerInputPacket.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
class PlayerInputPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::PLAYER_INPUT_PACKET;
|
||||
|
||||
public $motionX;
|
||||
public $motionY;
|
||||
public $unknownBool1;
|
||||
public $unknownBool2;
|
||||
|
||||
public function decode(){
|
||||
$this->motionX = $this->getLFloat();
|
||||
$this->motionY = $this->getLFloat();
|
||||
$this->unknownBool1 = $this->getByte();
|
||||
$this->unknownBool2 = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ class PlayerListPacket extends DataPacket{
|
||||
const TYPE_ADD = 0;
|
||||
const TYPE_REMOVE = 1;
|
||||
|
||||
//REMOVE: UUID, ADD: UUID, entity id, name, isSlim, skin
|
||||
//REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin
|
||||
/** @var array[] */
|
||||
public $entries = [];
|
||||
public $type;
|
||||
@ -51,7 +51,7 @@ class PlayerListPacket extends DataPacket{
|
||||
foreach($this->entries as $d){
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$this->putUUID($d[0]);
|
||||
$this->putLong($d[1]);
|
||||
$this->putEntityId($d[1]);
|
||||
$this->putString($d[2]);
|
||||
$this->putString($d[3]);
|
||||
$this->putString($d[4]);
|
||||
|
@ -27,16 +27,12 @@ namespace pocketmine\network\protocol;
|
||||
class RemoveBlockPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::REMOVE_BLOCK_PACKET;
|
||||
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
$this->eid = $this->getLong();
|
||||
$this->x = $this->getInt();
|
||||
$this->z = $this->getInt();
|
||||
$this->y = $this->getByte();
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
@ -35,7 +35,7 @@ class RemoveEntityPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 ReplaceSelectedItemPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::REPLACE_SELECTED_ITEM_PACKET;
|
||||
|
||||
public $item;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
}
|
@ -32,16 +32,16 @@ class RespawnPacket extends DataPacket{
|
||||
public $z;
|
||||
|
||||
public function decode(){
|
||||
$this->x = $this->getFloat();
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
$this->x = $this->getLFloat();
|
||||
$this->y = $this->getLFloat();
|
||||
$this->z = $this->getLFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putLFloat($this->x);
|
||||
$this->putLFloat($this->y);
|
||||
$this->putLFloat($this->z);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
41
src/pocketmine/network/protocol/SetCommandsEnabledPacket.php
Normal file
41
src/pocketmine/network/protocol/SetCommandsEnabledPacket.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 SetCommandsEnabledPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::SET_COMMANDS_ENABLED_PACKET;
|
||||
|
||||
public $enabled;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->enabled);
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,7 @@ class SetDifficultyPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->difficulty);
|
||||
$this->putUnsignedVarInt($this->difficulty);
|
||||
}
|
||||
|
||||
}
|
@ -40,7 +40,7 @@ class SetEntityDataPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->eid);
|
||||
$meta = Binary::writeMetadata($this->metadata);
|
||||
$this->put($meta);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class SetEntityLinkPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->from);
|
||||
$this->putLong($this->to);
|
||||
$this->putEntityId($this->from);
|
||||
$this->putEntityId($this->to);
|
||||
$this->putByte($this->type);
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace pocketmine\network\protocol;
|
||||
class SetEntityMotionPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::SET_ENTITY_MOTION_PACKET;
|
||||
|
||||
|
||||
// eid, motX, motY, motZ
|
||||
/** @var array[] */
|
||||
public $entities = [];
|
||||
public $eid;
|
||||
public $motionX;
|
||||
public $motionY;
|
||||
public $motionZ;
|
||||
|
||||
public function clean(){
|
||||
$this->entities = [];
|
||||
@ -43,13 +43,8 @@ class SetEntityMotionPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt(count($this->entities));
|
||||
foreach($this->entities as $d){
|
||||
$this->putLong($d[0]); //eid
|
||||
$this->putFloat($d[1]); //motX
|
||||
$this->putFloat($d[2]); //motY
|
||||
$this->putFloat($d[3]); //motZ
|
||||
}
|
||||
$this->putEntityId($this->eid);
|
||||
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class SetHealthPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->health);
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,7 @@ class SetPlayerGameTypePacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->gamemode);
|
||||
$this->putVarInt($this->gamemode);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\protocol;
|
||||
class SetSpawnPositionPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::SET_SPAWN_POSITION_PACKET;
|
||||
|
||||
public $unknown;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
@ -37,9 +38,8 @@ class SetSpawnPositionPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->y);
|
||||
$this->putInt($this->z);
|
||||
$this->putVarInt($this->unknown);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ class SetTimePacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->time);
|
||||
$this->putByte($this->started ? 1 : 0);
|
||||
$this->putVarInt($this->time);
|
||||
$this->putByte((int) $this->started);
|
||||
}
|
||||
|
||||
}
|
||||
|
44
src/pocketmine/network/protocol/SpawnExperienceOrbPacket.php
Normal file
44
src/pocketmine/network/protocol/SpawnExperienceOrbPacket.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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 SpawnExperienceOrbPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::SPAWN_EXPERIENCE_ORB_PACKET;
|
||||
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $amount;
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putVector3f($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->amount);
|
||||
}
|
||||
}
|
@ -36,8 +36,8 @@ class TakeItemEntityPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putLong($this->target);
|
||||
$this->putLong($this->eid);
|
||||
$this->putEntityId($this->target);
|
||||
$this->putEntityId($this->eid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,15 +40,13 @@ class UpdateAttributesPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
|
||||
$this->putLong($this->entityId);
|
||||
|
||||
$this->putShort(count($this->entries));
|
||||
|
||||
$this->putEntityId($this->entityId);
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
$this->putFloat($entry->getMinValue());
|
||||
$this->putFloat($entry->getMaxValue());
|
||||
$this->putFloat($entry->getValue());
|
||||
$this->putLFloat($entry->getMinValue());
|
||||
$this->putLFloat($entry->getMaxValue());
|
||||
$this->putLFloat($entry->getValue());
|
||||
$this->putLFloat($entry->getDefaultValue());
|
||||
$this->putString($entry->getName());
|
||||
}
|
||||
}
|
||||
|
@ -49,11 +49,9 @@ class UpdateBlockPacket extends DataPacket{
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->x);
|
||||
$this->putInt($this->z);
|
||||
$this->putByte($this->y);
|
||||
$this->putByte($this->blockId);
|
||||
$this->putByte(($this->flags << 4) | $this->blockData);
|
||||
$this->putBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->blockId);
|
||||
$this->putUnsignedVarInt(($this->flags << 4) | $this->blockData);
|
||||
}
|
||||
|
||||
}
|
@ -41,18 +41,11 @@ class UseItemPacket extends DataPacket{
|
||||
public $slot;
|
||||
|
||||
public function decode(){
|
||||
$this->x = $this->getInt();
|
||||
$this->y = $this->getInt();
|
||||
$this->z = $this->getInt();
|
||||
$this->face = $this->getByte();
|
||||
$this->fx = $this->getFloat();
|
||||
$this->fy = $this->getFloat();
|
||||
$this->fz = $this->getFloat();
|
||||
$this->posX = $this->getFloat();
|
||||
$this->posY = $this->getFloat();
|
||||
$this->posZ = $this->getFloat();
|
||||
$this->slot = $this->getInt();
|
||||
|
||||
$this->getBlockCoords($this->x, $this->y, $this->z);
|
||||
$this->face = $this->getVarInt();
|
||||
$this->getVector3f($this->fx, $this->fy, $this->fz);
|
||||
$this->getVector3f($this->posX, $this->posY, $this->posZ);
|
||||
$this->slot = $this->getVarInt();
|
||||
$this->item = $this->getSlot();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user