mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Merge network refactors
This commit is contained in:
commit
6de8415c79
@ -67,7 +67,6 @@ use pocketmine\event\player\PlayerToggleFlightEvent;
|
||||
use pocketmine\event\player\PlayerToggleSneakEvent;
|
||||
use pocketmine\event\player\PlayerToggleSprintEvent;
|
||||
use pocketmine\event\player\PlayerTransferEvent;
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\event\server\DataPacketSendEvent;
|
||||
use pocketmine\event\TextContainer;
|
||||
use pocketmine\event\Timings;
|
||||
@ -104,64 +103,39 @@ use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\LongTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\PlayerNetworkSessionAdapter;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
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;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\DropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
use pocketmine\network\mcpe\protocol\HurtArmorPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
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\ProtocolInfo;
|
||||
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\ReplaceItemInSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
@ -170,28 +144,18 @@ use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
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;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\network\SourceInterface;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
@ -208,7 +172,7 @@ use pocketmine\utils\UUID;
|
||||
/**
|
||||
* Main class that handles networking, recovery, and packet sending to the server part
|
||||
*/
|
||||
class Player extends Human implements CommandSender, ChunkLoader, IPlayer, NetworkSession{
|
||||
class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
const SURVIVAL = 0;
|
||||
const CREATIVE = 1;
|
||||
@ -241,6 +205,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
/** @var SourceInterface */
|
||||
protected $interface;
|
||||
|
||||
/**
|
||||
* @var PlayerNetworkSessionAdapter
|
||||
* TODO: remove this once player and network are divorced properly
|
||||
*/
|
||||
protected $sessionAdapter;
|
||||
|
||||
/** @var bool */
|
||||
public $playedBefore;
|
||||
public $spawned = false;
|
||||
@ -682,6 +652,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
|
||||
$this->allowMovementCheats = (bool) $this->server->getProperty("player.anti-cheat.allow-movement-cheats", false);
|
||||
$this->allowInstaBreak = (bool) $this->server->getProperty("player.anti-cheat.allow-instabreak", false);
|
||||
|
||||
$this->sessionAdapter = new PlayerNetworkSessionAdapter($this->server, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1982,10 +1954,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handlePlayStatus(PlayStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sendPlayStatus(int $status, bool $immediate = false){
|
||||
$pk = new PlayStatusPacket();
|
||||
$pk->status = $status;
|
||||
@ -1996,26 +1964,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleDisconnect(DisconnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
switch($packet->status){
|
||||
case ResourcePackClientResponsePacket::STATUS_REFUSED:
|
||||
@ -2102,42 +2054,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleSetTime(SetTimePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStartGame(StartGamePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPlayer(AddPlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntity(MoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
$newPos = new Vector3($packet->x, $packet->y - $this->baseOffset, $packet->z);
|
||||
|
||||
@ -2167,10 +2083,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2210,32 +2122,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPainting(AddPaintingPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleExplode(ExplodePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||
//TODO: add events so plugins can change this
|
||||
$this->getLevel()->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleLevelEvent(LevelEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEvent(BlockEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2268,14 +2160,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleMobEffect(MobEffectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2307,10 +2191,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2821,34 +2701,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
return true; //not used
|
||||
}
|
||||
|
||||
public function handleHurtArmor(HurtArmorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetHealth(SetHealthPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2867,10 +2719,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleRespawn(RespawnPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleDropItem(DropItemPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -2899,14 +2747,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleInventoryAction(InventoryActionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerOpen(ContainerOpenPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
if($this->spawned === false or $packet->windowid === 0){
|
||||
return true;
|
||||
@ -2934,21 +2774,21 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
}
|
||||
|
||||
switch($packet->windowid){
|
||||
case ContainerSetContentPacket::SPECIAL_INVENTORY: //Normal inventory change
|
||||
case ContainerIds::INVENTORY: //Normal inventory change
|
||||
if($packet->slot >= $this->inventory->getSize()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$transaction = new BaseTransaction($this->inventory, $packet->slot, $this->inventory->getItem($packet->slot), $packet->item);
|
||||
break;
|
||||
case ContainerSetContentPacket::SPECIAL_ARMOR: //Armour change
|
||||
case ContainerIds::ARMOR: //Armour change
|
||||
if($packet->slot >= 4){
|
||||
return false;
|
||||
}
|
||||
|
||||
$transaction = new BaseTransaction($this->inventory, $packet->slot + $this->inventory->getSize(), $this->inventory->getArmorItem($packet->slot), $packet->item);
|
||||
break;
|
||||
case ContainerSetContentPacket::SPECIAL_HOTBAR: //Hotbar link update
|
||||
case ContainerIds::HOTBAR: //Hotbar link update
|
||||
//hotbarSlot 0-8, slot 9-44
|
||||
$this->inventory->setHotbarSlotIndex($packet->hotbarSlot, $packet->slot - 9);
|
||||
return true;
|
||||
@ -3009,18 +2849,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetContent(ContainerSetContentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingData(CraftingDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -3238,22 +3066,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
if($packet->gamemode !== $this->gamemode){
|
||||
//Set this back to default. TODO: handle this properly
|
||||
@ -3263,18 +3075,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handlePlayerList(PlayerListPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
@ -3285,10 +3089,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -3318,18 +3118,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleReplaceItemInSlot(ReplaceItemInSlotPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItem(AddItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
@ -3338,10 +3126,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return false; //TODO: handle resume
|
||||
}
|
||||
|
||||
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
return true;
|
||||
@ -3369,18 +3153,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
$manager = $this->server->getResourceManager();
|
||||
$pack = $manager->getPackById($packet->packId);
|
||||
@ -3400,52 +3172,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleTransfer(TransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlaySound(PlaySoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStopSound(StopSoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTitle(SetTitlePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a packet is received from the client. This method will call DataPacketReceiveEvent.
|
||||
*
|
||||
* @param DataPacket $packet
|
||||
*/
|
||||
public function handleDataPacket(DataPacket $packet){
|
||||
if($this->connected === false){
|
||||
return;
|
||||
if($this->sessionAdapter !== null){
|
||||
$this->sessionAdapter->handleDataPacket($packet);
|
||||
}
|
||||
|
||||
//TODO: Remove this hack once InteractPacket spam issue is fixed
|
||||
if($packet->buffer === "\x21\x04\x00"){
|
||||
return;
|
||||
}
|
||||
|
||||
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
|
||||
$packet->decode();
|
||||
if(!$packet->feof()){
|
||||
$remains = substr($packet->buffer, $packet->offset);
|
||||
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
||||
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3669,6 +3404,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
|
||||
$this->directDataPacket($pk);
|
||||
}
|
||||
|
||||
$this->sessionAdapter = null;
|
||||
$this->connected = false;
|
||||
|
||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
||||
|
@ -257,6 +257,7 @@ class Server{
|
||||
/** @var Player[] */
|
||||
private $playerList = [];
|
||||
|
||||
/** @var string[] */
|
||||
private $identifiers = [];
|
||||
|
||||
/** @var Level[] */
|
||||
@ -1816,7 +1817,6 @@ class Server{
|
||||
*/
|
||||
public function broadcastPacket(array $players, DataPacket $packet){
|
||||
$packet->encode();
|
||||
$packet->isEncoded = true;
|
||||
$this->batchPackets($players, [$packet], false);
|
||||
}
|
||||
|
||||
@ -1846,17 +1846,16 @@ class Server{
|
||||
}
|
||||
|
||||
if(Network::$BATCH_THRESHOLD >= 0 and strlen($pk->payload) >= Network::$BATCH_THRESHOLD){
|
||||
$compressionLevel = $this->networkCompressionLevel;
|
||||
$pk->setCompressionLevel($this->networkCompressionLevel);
|
||||
}else{
|
||||
$compressionLevel = 0; //Do not compress packets under the threshold
|
||||
$pk->setCompressionLevel(0); //Do not compress packets under the threshold
|
||||
$forceSync = true;
|
||||
}
|
||||
|
||||
if(!$forceSync and !$immediate and $this->networkCompressionAsync){
|
||||
$task = new CompressBatchedTask($pk, $targets, $compressionLevel);
|
||||
$task = new CompressBatchedTask($pk, $targets);
|
||||
$this->getScheduler()->scheduleAsyncTask($task);
|
||||
}else{
|
||||
$pk->compress($compressionLevel);
|
||||
$this->broadcastPacketsCallback($pk, $targets, $immediate);
|
||||
}
|
||||
}
|
||||
@ -1867,7 +1866,6 @@ class Server{
|
||||
public function broadcastPacketsCallback(BatchPacket $pk, array $identifiers, bool $immediate = false){
|
||||
if(!$pk->isEncoded){
|
||||
$pk->encode();
|
||||
$pk->isEncoded = true;
|
||||
}
|
||||
|
||||
if($immediate){
|
||||
|
@ -112,7 +112,6 @@ class CraftingManager{
|
||||
}
|
||||
|
||||
$pk->encode();
|
||||
$pk->isEncoded = true;
|
||||
|
||||
$this->craftingDataCache = $pk;
|
||||
Timings::$craftingDataCacheRebuildTimer->stopTiming();
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
@ -238,7 +239,7 @@ class PlayerInventory extends BaseInventory{
|
||||
$pk->item = $item;
|
||||
$pk->inventorySlot = $this->getHeldItemSlot();
|
||||
$pk->hotbarSlot = $this->getHeldItemIndex();
|
||||
$pk->windowId = ContainerSetContentPacket::SPECIAL_INVENTORY;
|
||||
$pk->windowId = ContainerIds::INVENTORY;
|
||||
|
||||
if(!is_array($target)){
|
||||
$target->dataPacket($pk);
|
||||
@ -419,12 +420,11 @@ class PlayerInventory extends BaseInventory{
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->slots = $armor;
|
||||
$pk->encode();
|
||||
$pk->isEncoded = true;
|
||||
|
||||
foreach($target as $player){
|
||||
if($player === $this->getHolder()){
|
||||
$pk2 = new ContainerSetContentPacket();
|
||||
$pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR;
|
||||
$pk2->windowid = ContainerIds::ARMOR;
|
||||
$pk2->slots = $armor;
|
||||
$pk2->targetEid = $player->getId();
|
||||
$player->dataPacket($pk2);
|
||||
@ -467,13 +467,12 @@ class PlayerInventory extends BaseInventory{
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->slots = $armor;
|
||||
$pk->encode();
|
||||
$pk->isEncoded = true;
|
||||
|
||||
foreach($target as $player){
|
||||
if($player === $this->getHolder()){
|
||||
/** @var Player $player */
|
||||
$pk2 = new ContainerSetSlotPacket();
|
||||
$pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR;
|
||||
$pk2->windowid = ContainerIds::ARMOR;
|
||||
$pk2->slot = $index - $this->getSize();
|
||||
$pk2->item = $this->getItem($index);
|
||||
$player->dataPacket($pk2);
|
||||
@ -523,7 +522,7 @@ class PlayerInventory extends BaseInventory{
|
||||
|
||||
public function sendCreativeContents(){
|
||||
$pk = new ContainerSetContentPacket();
|
||||
$pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
|
||||
$pk->windowid = ContainerIds::CREATIVE;
|
||||
if($this->getHolder()->getGamemode() === Player::CREATIVE){
|
||||
foreach(Item::getCreativeItems() as $i => $item){
|
||||
$pk->slots[$i] = clone $item;
|
||||
|
@ -75,7 +75,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
$batch->compress($this->compressionLevel);
|
||||
$batch->setCompressionLevel($this->compressionLevel);
|
||||
$batch->encode();
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
@ -87,7 +87,6 @@ class ChunkRequestTask extends AsyncTask{
|
||||
if($this->hasResult()){
|
||||
$batch = new BatchPacket($this->getResult());
|
||||
assert(strlen($batch->buffer) > 0);
|
||||
$batch->compressed = true;
|
||||
$batch->isEncoded = true;
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $batch);
|
||||
}else{
|
||||
|
@ -33,10 +33,14 @@ class CompressBatchedTask extends AsyncTask{
|
||||
public $data;
|
||||
public $targets;
|
||||
|
||||
public function __construct(BatchPacket $batch, array $targets, $level = 7){
|
||||
/**
|
||||
* @param BatchPacket $batch
|
||||
* @param string[] $targets
|
||||
*/
|
||||
public function __construct(BatchPacket $batch, array $targets){
|
||||
$this->data = $batch->payload;
|
||||
$this->targets = serialize($targets);
|
||||
$this->level = $level;
|
||||
$this->level = $batch->getCompressionLevel();
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
@ -44,7 +48,7 @@ class CompressBatchedTask extends AsyncTask{
|
||||
$batch->payload = $this->data;
|
||||
$this->data = null;
|
||||
|
||||
$batch->compress($this->level);
|
||||
$batch->setCompressionLevel($this->level);
|
||||
$batch->encode();
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
@ -53,7 +57,6 @@ class CompressBatchedTask extends AsyncTask{
|
||||
public function onCompletion(Server $server){
|
||||
$pk = new BatchPacket($this->getResult());
|
||||
$pk->isEncoded = true;
|
||||
$pk->compressed = true;
|
||||
$server->broadcastPacketsCallback($pk, unserialize($this->targets));
|
||||
}
|
||||
}
|
||||
|
@ -26,104 +26,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace pocketmine\network;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
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;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\DropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
use pocketmine\network\mcpe\protocol\HurtArmorPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
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\ProtocolInfo;
|
||||
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\ReplaceItemInSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
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;
|
||||
use pocketmine\network\mcpe\protocol\UnknownPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Network{
|
||||
|
||||
public static $BATCH_THRESHOLD = 512;
|
||||
|
||||
/** @var \SplFixedArray */
|
||||
private $packetPool;
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
@ -139,8 +48,7 @@ class Network{
|
||||
private $name;
|
||||
|
||||
public function __construct(Server $server){
|
||||
|
||||
$this->registerPackets();
|
||||
PacketPool::init();
|
||||
|
||||
$this->server = $server;
|
||||
|
||||
@ -230,33 +138,10 @@ class Network{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id 0-255
|
||||
* @param DataPacket $class
|
||||
*/
|
||||
public function registerPacket($id, $class){
|
||||
$this->packetPool[$id] = new $class;
|
||||
}
|
||||
|
||||
public function getServer(){
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return DataPacket
|
||||
*/
|
||||
public function getPacket($id){
|
||||
/** @var DataPacket $class */
|
||||
$class = $this->packetPool[$id];
|
||||
if($class !== null){
|
||||
return clone $class;
|
||||
}
|
||||
return new UnknownPacket();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
* @param int $port
|
||||
@ -279,96 +164,4 @@ class Network{
|
||||
$interface->blockAddress($address, $timeout);
|
||||
}
|
||||
}
|
||||
|
||||
private function registerPackets(){
|
||||
$this->packetPool = new \SplFixedArray(256);
|
||||
|
||||
$this->registerPacket(ProtocolInfo::ADD_ENTITY_PACKET, AddEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_HANGING_ENTITY_PACKET, AddHangingEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_ITEM_PACKET, AddItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ADD_PAINTING_PACKET, AddPaintingPacket::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::AVAILABLE_COMMANDS_PACKET, AvailableCommandsPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_PICK_REQUEST_PACKET, BlockPickRequestPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BOSS_EVENT_PACKET, BossEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CLIENTBOUND_MAP_ITEM_DATA_PACKET, ClientboundMapItemDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET, ClientToServerHandshakePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET, CommandBlockUpdatePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::COMMAND_STEP_PACKET, CommandStepPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, ContainerClosePacket::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::DISCONNECT_PACKET, DisconnectPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::ENTITY_FALL_PACKET, EntityFallPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::GAME_RULES_CHANGED_PACKET, GameRulesChangedPacket::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::MAP_INFO_REQUEST_PACKET, MapInfoRequestPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::MOB_EFFECT_PACKET, MobEffectPacket::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_SOUND_PACKET, PlaySoundPacket::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_ITEM_IN_SLOT_PACKET, ReplaceItemInSlotPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACKS_INFO_PACKET, ResourcePacksInfoPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET, ResourcePackChunkDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET, ResourcePackChunkRequestPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET, ResourcePackClientResponsePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET, ResourcePackDataInfoPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESOURCE_PACK_STACK_PACKET, ResourcePackStackPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::RIDER_JUMP_PACKET, RiderJumpPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SERVER_TO_CLIENT_HANDSHAKE_PACKET, ServerToClientHandshakePacket::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_GAME_TYPE_PACKET, SetPlayerGameTypePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SET_TITLE_PACKET, SetTitlePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SHOW_CREDITS_PACKET, ShowCreditsPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET, SpawnExperienceOrbPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::STOP_SOUND_PACKET, StopSoundPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TRANSFER_PACKET, TransferPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_ATTRIBUTES_PACKET, UpdateAttributesPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_TRADE_PACKET, UpdateTradePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
|
||||
|
||||
$this->registerPacket(0xfe, BatchPacket::class);
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
@ -38,10 +37,11 @@ use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\CameraPacket;
|
||||
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\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandStepPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
@ -55,6 +55,8 @@ use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\DropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
@ -71,12 +73,12 @@ use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
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\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\ReplaceItemInSlotPacket;
|
||||
@ -85,8 +87,8 @@ use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
@ -101,198 +103,395 @@ 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\ShowStoreOfferPacket;
|
||||
use pocketmine\network\mcpe\protocol\SimpleEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\Server;
|
||||
|
||||
interface NetworkSession{
|
||||
abstract class NetworkSession{
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer();
|
||||
abstract public function handleDataPacket(DataPacket $packet);
|
||||
|
||||
public function handleDataPacket(DataPacket $pk);
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool;
|
||||
public function handlePlayStatus(PlayStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayStatus(PlayStatusPacket $packet) : bool;
|
||||
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool;
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool;
|
||||
public function handleDisconnect(DisconnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleDisconnect(DisconnectPacket $packet) : bool;
|
||||
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool;
|
||||
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool;
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool;
|
||||
public function handleText(TextPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleText(TextPacket $packet) : bool;
|
||||
public function handleSetTime(SetTimePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTime(SetTimePacket $packet) : bool;
|
||||
public function handleStartGame(StartGamePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStartGame(StartGamePacket $packet) : bool;
|
||||
public function handleAddPlayer(AddPlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPlayer(AddPlayerPacket $packet) : bool;
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool;
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool;
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool;
|
||||
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool;
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool;
|
||||
public function handleMoveEntity(MoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntity(MoveEntityPacket $packet) : bool;
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool;
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool;
|
||||
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool;
|
||||
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool;
|
||||
public function handleAddPainting(AddPaintingPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPainting(AddPaintingPacket $packet) : bool;
|
||||
public function handleExplode(ExplodePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleExplode(ExplodePacket $packet) : bool;
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool;
|
||||
public function handleLevelEvent(LevelEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelEvent(LevelEventPacket $packet) : bool;
|
||||
public function handleBlockEvent(BlockEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEvent(BlockEventPacket $packet) : bool;
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool;
|
||||
public function handleMobEffect(MobEffectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEffect(MobEffectPacket $packet) : bool;
|
||||
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool;
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool;
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool;
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool;
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool;
|
||||
public function handleUseItem(UseItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUseItem(UseItemPacket $packet) : bool;
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool;
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool;
|
||||
public function handleHurtArmor(HurtArmorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleHurtArmor(HurtArmorPacket $packet) : bool;
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool;
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool;
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool;
|
||||
public function handleSetHealth(SetHealthPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetHealth(SetHealthPacket $packet) : bool;
|
||||
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool;
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool;
|
||||
public function handleRespawn(RespawnPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRespawn(RespawnPacket $packet) : bool;
|
||||
public function handleDropItem(DropItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleDropItem(DropItemPacket $packet) : bool;
|
||||
public function handleInventoryAction(InventoryActionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventoryAction(InventoryActionPacket $packet) : bool;
|
||||
public function handleContainerOpen(ContainerOpenPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerOpen(ContainerOpenPacket $packet) : bool;
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool;
|
||||
public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool;
|
||||
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool;
|
||||
public function handleContainerSetContent(ContainerSetContentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetContent(ContainerSetContentPacket $packet) : bool;
|
||||
public function handleCraftingData(CraftingDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingData(CraftingDataPacket $packet) : bool;
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool;
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool;
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool;
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool;
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool;
|
||||
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool;
|
||||
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool;
|
||||
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool;
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool;
|
||||
public function handlePlayerList(PlayerListPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerList(PlayerListPacket $packet) : bool;
|
||||
public function handleSimpleEvent(SimpleEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
//public function handleTelemetryEvent(EventPacket $packet) : bool; //TODO
|
||||
public function handleEvent(EventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool;
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool;
|
||||
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool; //TODO
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool;
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool;
|
||||
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool;
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleReplaceItemInSlot(ReplaceItemInSlotPacket $packet) : bool;
|
||||
public function handleReplaceItemInSlot(ReplaceItemInSlotPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool;
|
||||
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
//public function handleCamera(CameraPacket $packet) : bool; //edu only :(
|
||||
public function handleCamera(CameraPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItem(AddItemPacket $packet) : bool;
|
||||
public function handleAddItem(AddItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool;
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool;
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool;
|
||||
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool;
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool;
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool;
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool;
|
||||
public function handleUpdateEquip(UpdateEquipPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool;
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool;
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTransfer(TransferPacket $packet) : bool;
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlaySound(PlaySoundPacket $packet) : bool;
|
||||
public function handleTransfer(TransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStopSound(StopSoundPacket $packet) : bool;
|
||||
public function handlePlaySound(PlaySoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStopSound(StopSoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTitle(SetTitlePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddBehaviorTree(AddBehaviorTreePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStructureBlockUpdate(StructureBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowStoreOffer(ShowStoreOfferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePurchaseReceipt(PurchaseReceiptPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTitle(SetTitlePacket $packet) : bool;
|
||||
}
|
232
src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php
Normal file
232
src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php
Normal file
@ -0,0 +1,232 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
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\ContainerSetSlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
/** @var Player */
|
||||
private $player;
|
||||
|
||||
public function __construct(Server $server, Player $player){
|
||||
$this->server = $server;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function handleDataPacket(DataPacket $packet){
|
||||
//TODO: Remove this hack once InteractPacket spam issue is fixed
|
||||
if($packet->buffer === "\x21\x04\x00"){
|
||||
return;
|
||||
}
|
||||
|
||||
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
|
||||
$packet->decode();
|
||||
if(!$packet->feof()){
|
||||
$remains = substr($packet->buffer, $packet->offset);
|
||||
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this->player, $packet));
|
||||
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
return $this->player->handleLogin($packet);
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return $this->player->handleClientToServerHandshake($packet);
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
return $this->player->handleResourcePackClientResponse($packet);
|
||||
}
|
||||
|
||||
public function handleText(TextPacket $packet) : bool{
|
||||
return $this->player->handleText($packet);
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
return $this->player->handleMovePlayer($packet);
|
||||
}
|
||||
|
||||
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{
|
||||
return $this->player->handleRemoveBlock($packet);
|
||||
}
|
||||
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||
return $this->player->handleLevelSoundEvent($packet);
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
return $this->player->handleEntityEvent($packet);
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
return $this->player->handleMobEquipment($packet);
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
return true; //Not used
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
return $this->player->handleInteract($packet);
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return $this->player->handleBlockPickRequest($packet);
|
||||
}
|
||||
|
||||
public function handleUseItem(UseItemPacket $packet) : bool{
|
||||
return $this->player->handleUseItem($packet);
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
return $this->player->handlePlayerAction($packet);
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
return true; //Not used
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
return $this->player->handleAnimate($packet);
|
||||
}
|
||||
|
||||
public function handleDropItem(DropItemPacket $packet) : bool{
|
||||
return $this->player->handleDropItem($packet);
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
return $this->player->handleContainerClose($packet);
|
||||
}
|
||||
|
||||
public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{
|
||||
return $this->player->handleContainerSetSlot($packet);
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
return $this->player->handleCraftingEvent($packet);
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
return $this->player->handleAdventureSettings($packet);
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
return $this->player->handleBlockEntityData($packet);
|
||||
}
|
||||
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool{
|
||||
return $this->player->handlePlayerInput($packet);
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
return $this->player->handleSetPlayerGameType($packet);
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
return $this->player->handleSpawnExperienceOrb($packet);
|
||||
}
|
||||
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool{
|
||||
return $this->player->handleMapInfoRequest($packet);
|
||||
}
|
||||
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||
return $this->player->handleRequestChunkRadius($packet);
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
return $this->player->handleItemFrameDropItem($packet);
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return $this->player->handleBossEvent($packet);
|
||||
}
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool{
|
||||
return $this->player->handleShowCredits($packet);
|
||||
}
|
||||
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool{
|
||||
return $this->player->handleCommandStep($packet);
|
||||
}
|
||||
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
|
||||
return $this->player->handleCommandBlockUpdate($packet);
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
return $this->player->handleResourcePackChunkRequest($packet);
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ use pocketmine\event\player\PlayerCreationEvent;
|
||||
use pocketmine\network\AdvancedSourceInterface;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\Player;
|
||||
@ -142,9 +143,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer));
|
||||
$logger->logException($e);
|
||||
|
||||
if(isset($this->players[$identifier])){
|
||||
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
|
||||
}
|
||||
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,7 +198,6 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$identifier = $this->identifiers[$h];
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
$packet->isEncoded = true;
|
||||
}
|
||||
|
||||
if($packet instanceof BatchPacket){
|
||||
@ -236,7 +234,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
|
||||
private function getPacket($buffer){
|
||||
$pid = ord($buffer{0});
|
||||
if(($data = $this->network->getPacket($pid)) === null){
|
||||
if(($data = PacketPool::getPacketById($pid)) === null){
|
||||
return null;
|
||||
}
|
||||
$data->setBuffer($buffer, 1);
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddBehaviorTreePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET;
|
||||
|
||||
/** @var string */
|
||||
public $unknownString1;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->unknownString1 = $this->getString();
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putString($this->unknownString1);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddBehaviorTree($this);
|
||||
}
|
||||
}
|
@ -30,12 +30,15 @@ use pocketmine\network\mcpe\NetworkSession;
|
||||
#ifndef COMPILE
|
||||
use pocketmine\utils\Binary;
|
||||
#endif
|
||||
use pocketmine\utils\BinaryStream;
|
||||
|
||||
class BatchPacket extends DataPacket{
|
||||
const NETWORK_ID = 0xfe;
|
||||
|
||||
public $payload;
|
||||
public $compressed = false;
|
||||
/** @var string */
|
||||
public $payload = "";
|
||||
/** @var int */
|
||||
protected $compressionLevel = 7;
|
||||
|
||||
public function canBeBatched() : bool{
|
||||
return false;
|
||||
@ -46,12 +49,16 @@ class BatchPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function decodePayload(){
|
||||
$this->payload = $this->getRemaining();
|
||||
$data = $this->getRemaining();
|
||||
try{
|
||||
$this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB
|
||||
}catch(\ErrorException $e){ //zlib decode error
|
||||
$this->payload = "";
|
||||
}
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
assert($this->compressed);
|
||||
$this->put($this->payload);
|
||||
$this->put(zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $this->compressionLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,33 +75,31 @@ class BatchPacket extends DataPacket{
|
||||
$this->payload .= Binary::writeUnsignedVarInt(strlen($packet->buffer)) . $packet->buffer;
|
||||
}
|
||||
|
||||
public function compress(int $level = 7){
|
||||
assert(!$this->compressed);
|
||||
$this->payload = zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $level);
|
||||
$this->compressed = true;
|
||||
/**
|
||||
* @return \Generator
|
||||
*/
|
||||
public function getPackets(){
|
||||
$stream = new BinaryStream($this->payload);
|
||||
while(!$stream->feof()){
|
||||
yield $stream->getString();
|
||||
}
|
||||
}
|
||||
|
||||
public function getCompressionLevel() : int{
|
||||
return $this->compressionLevel;
|
||||
}
|
||||
|
||||
public function setCompressionLevel(int $level){
|
||||
$this->compressionLevel = $level;
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
if(strlen($this->payload) < 2){
|
||||
if($this->payload === ""){
|
||||
return false;
|
||||
}
|
||||
|
||||
try{
|
||||
$str = zlib_decode($this->payload, 1024 * 1024 * 64); //Max 64MB
|
||||
}catch(\ErrorException $e){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($str === ""){
|
||||
throw new \InvalidStateException("Decoded BatchPacket payload is empty");
|
||||
}
|
||||
|
||||
$this->setBuffer($str, 0);
|
||||
|
||||
$network = $session->getServer()->getNetwork();
|
||||
while(!$this->feof()){
|
||||
$buf = $this->getString();
|
||||
$pk = $network->getPacket(ord($buf{0}));
|
||||
foreach($this->getPackets() as $buf){
|
||||
$pk = PacketPool::getPacketById(ord($buf{0}));
|
||||
|
||||
if(!$pk->canBeBatched()){
|
||||
throw new \InvalidArgumentException("Received invalid " . get_class($pk) . " inside BatchPacket");
|
||||
|
51
src/pocketmine/network/mcpe/protocol/CameraPacket.php
Normal file
51
src/pocketmine/network/mcpe/protocol/CameraPacket.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CameraPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CAMERA_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $cameraUniqueId;
|
||||
/** @var int */
|
||||
public $playerUniqueId;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->cameraUniqueId = $this->getEntityUniqueId();
|
||||
$this->playerUniqueId = $this->getEntityUniqueId();
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putEntityUniqueId($this->cameraUniqueId);
|
||||
$this->putEntityUniqueId($this->playerUniqueId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCamera($this);
|
||||
}
|
||||
}
|
@ -27,17 +27,11 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
|
||||
class ContainerSetContentPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
|
||||
|
||||
const SPECIAL_INVENTORY = 0;
|
||||
const SPECIAL_OFFHAND = 0x77;
|
||||
const SPECIAL_ARMOR = 0x78;
|
||||
const SPECIAL_CREATIVE = 0x79;
|
||||
const SPECIAL_HOTBAR = 0x7a;
|
||||
const SPECIAL_FIXED_INVENTORY = 0x7b;
|
||||
|
||||
public $windowid;
|
||||
public $targetEid;
|
||||
public $slots = [];
|
||||
@ -70,7 +64,7 @@ class ContainerSetContentPacket extends DataPacket{
|
||||
foreach($this->slots as $slot){
|
||||
$this->putSlot($slot);
|
||||
}
|
||||
if($this->windowid === self::SPECIAL_INVENTORY and count($this->hotbar) > 0){
|
||||
if($this->windowid === ContainerIds::INVENTORY and count($this->hotbar) > 0){
|
||||
$this->putUnsignedVarInt(count($this->hotbar));
|
||||
foreach($this->hotbar as $slot){
|
||||
$this->putVarInt($slot);
|
||||
|
@ -70,6 +70,7 @@ abstract class DataPacket extends BinaryStream{
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->encodePayload();
|
||||
$this->isEncoded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
67
src/pocketmine/network/mcpe/protocol/EventPacket.php
Normal file
67
src/pocketmine/network/mcpe/protocol/EventPacket.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?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\NetworkSession;
|
||||
|
||||
class EventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::EVENT_PACKET;
|
||||
|
||||
const TYPE_ACHIEVEMENT_AWARDED = 0;
|
||||
const TYPE_ENTITY_INTERACT = 1;
|
||||
const TYPE_PORTAL_BUILT = 2;
|
||||
const TYPE_PORTAL_USED = 3;
|
||||
const TYPE_MOB_KILLED = 4;
|
||||
const TYPE_CAULDRON_USED = 5;
|
||||
const TYPE_PLAYER_DEATH = 6;
|
||||
const TYPE_BOSS_KILLED = 7;
|
||||
const TYPE_AGENT_COMMAND = 8;
|
||||
const TYPE_AGENT_CREATED = 9;
|
||||
|
||||
public $playerRuntimeId;
|
||||
public $eventData;
|
||||
public $type;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->playerRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->eventData = $this->getVarInt();
|
||||
$this->type = $this->getByte();
|
||||
|
||||
//TODO: nice confusing mess
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->playerRuntimeId);
|
||||
$this->putVarInt($this->eventData);
|
||||
$this->putByte($this->type);
|
||||
|
||||
//TODO: also nice confusing mess
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEvent($this);
|
||||
}
|
||||
}
|
157
src/pocketmine/network/mcpe/protocol/PacketPool.php
Normal file
157
src/pocketmine/network/mcpe/protocol/PacketPool.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?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;
|
||||
|
||||
class PacketPool{
|
||||
/** @var \SplFixedArray<DataPacket> */
|
||||
protected static $pool = null;
|
||||
|
||||
public static function init(){
|
||||
static::$pool = new \SplFixedArray(256);
|
||||
|
||||
//Normal packets
|
||||
static::registerPacket(new LoginPacket());
|
||||
static::registerPacket(new PlayStatusPacket());
|
||||
static::registerPacket(new ServerToClientHandshakePacket());
|
||||
static::registerPacket(new ClientToServerHandshakePacket());
|
||||
static::registerPacket(new DisconnectPacket());
|
||||
static::registerPacket(new ResourcePacksInfoPacket());
|
||||
static::registerPacket(new ResourcePackStackPacket());
|
||||
static::registerPacket(new ResourcePackClientResponsePacket());
|
||||
static::registerPacket(new TextPacket());
|
||||
static::registerPacket(new SetTimePacket());
|
||||
static::registerPacket(new StartGamePacket());
|
||||
static::registerPacket(new AddPlayerPacket());
|
||||
static::registerPacket(new AddEntityPacket());
|
||||
static::registerPacket(new RemoveEntityPacket());
|
||||
static::registerPacket(new AddItemEntityPacket());
|
||||
static::registerPacket(new AddHangingEntityPacket());
|
||||
static::registerPacket(new TakeItemEntityPacket());
|
||||
static::registerPacket(new MoveEntityPacket());
|
||||
static::registerPacket(new MovePlayerPacket());
|
||||
static::registerPacket(new RiderJumpPacket());
|
||||
static::registerPacket(new RemoveBlockPacket());
|
||||
static::registerPacket(new UpdateBlockPacket());
|
||||
static::registerPacket(new AddPaintingPacket());
|
||||
static::registerPacket(new ExplodePacket());
|
||||
static::registerPacket(new LevelSoundEventPacket());
|
||||
static::registerPacket(new LevelEventPacket());
|
||||
static::registerPacket(new BlockEventPacket());
|
||||
static::registerPacket(new EntityEventPacket());
|
||||
static::registerPacket(new MobEffectPacket());
|
||||
static::registerPacket(new UpdateAttributesPacket());
|
||||
static::registerPacket(new MobEquipmentPacket());
|
||||
static::registerPacket(new MobArmorEquipmentPacket());
|
||||
static::registerPacket(new InteractPacket());
|
||||
static::registerPacket(new BlockPickRequestPacket());
|
||||
static::registerPacket(new UseItemPacket());
|
||||
static::registerPacket(new PlayerActionPacket());
|
||||
static::registerPacket(new EntityFallPacket());
|
||||
static::registerPacket(new HurtArmorPacket());
|
||||
static::registerPacket(new SetEntityDataPacket());
|
||||
static::registerPacket(new SetEntityMotionPacket());
|
||||
static::registerPacket(new SetEntityLinkPacket());
|
||||
static::registerPacket(new SetHealthPacket());
|
||||
static::registerPacket(new SetSpawnPositionPacket());
|
||||
static::registerPacket(new AnimatePacket());
|
||||
static::registerPacket(new RespawnPacket());
|
||||
static::registerPacket(new DropItemPacket());
|
||||
static::registerPacket(new InventoryActionPacket());
|
||||
static::registerPacket(new ContainerOpenPacket());
|
||||
static::registerPacket(new ContainerClosePacket());
|
||||
static::registerPacket(new ContainerSetSlotPacket());
|
||||
static::registerPacket(new ContainerSetDataPacket());
|
||||
static::registerPacket(new ContainerSetContentPacket());
|
||||
static::registerPacket(new CraftingDataPacket());
|
||||
static::registerPacket(new CraftingEventPacket());
|
||||
static::registerPacket(new AdventureSettingsPacket());
|
||||
static::registerPacket(new BlockEntityDataPacket());
|
||||
static::registerPacket(new PlayerInputPacket());
|
||||
static::registerPacket(new FullChunkDataPacket());
|
||||
static::registerPacket(new SetCommandsEnabledPacket());
|
||||
static::registerPacket(new SetDifficultyPacket());
|
||||
static::registerPacket(new ChangeDimensionPacket());
|
||||
static::registerPacket(new SetPlayerGameTypePacket());
|
||||
static::registerPacket(new PlayerListPacket());
|
||||
static::registerPacket(new SimpleEventPacket());
|
||||
static::registerPacket(new EventPacket());
|
||||
static::registerPacket(new SpawnExperienceOrbPacket());
|
||||
static::registerPacket(new ClientboundMapItemDataPacket());
|
||||
static::registerPacket(new MapInfoRequestPacket());
|
||||
static::registerPacket(new RequestChunkRadiusPacket());
|
||||
static::registerPacket(new ChunkRadiusUpdatedPacket());
|
||||
static::registerPacket(new ItemFrameDropItemPacket());
|
||||
static::registerPacket(new ReplaceItemInSlotPacket());
|
||||
static::registerPacket(new GameRulesChangedPacket());
|
||||
static::registerPacket(new CameraPacket());
|
||||
static::registerPacket(new AddItemPacket());
|
||||
static::registerPacket(new BossEventPacket());
|
||||
static::registerPacket(new ShowCreditsPacket());
|
||||
static::registerPacket(new AvailableCommandsPacket());
|
||||
static::registerPacket(new CommandStepPacket());
|
||||
static::registerPacket(new CommandBlockUpdatePacket());
|
||||
static::registerPacket(new UpdateTradePacket());
|
||||
static::registerPacket(new UpdateEquipPacket());
|
||||
static::registerPacket(new ResourcePackDataInfoPacket());
|
||||
static::registerPacket(new ResourcePackChunkDataPacket());
|
||||
static::registerPacket(new ResourcePackChunkRequestPacket());
|
||||
static::registerPacket(new TransferPacket());
|
||||
static::registerPacket(new PlaySoundPacket());
|
||||
static::registerPacket(new StopSoundPacket());
|
||||
static::registerPacket(new SetTitlePacket());
|
||||
static::registerPacket(new AddBehaviorTreePacket());
|
||||
static::registerPacket(new StructureBlockUpdatePacket());
|
||||
static::registerPacket(new ShowStoreOfferPacket());
|
||||
static::registerPacket(new PurchaseReceiptPacket());
|
||||
|
||||
static::registerPacket(new BatchPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataPacket $packet
|
||||
*/
|
||||
public static function registerPacket(DataPacket $packet){
|
||||
static::$pool[$packet->pid()] = clone $packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pid
|
||||
* @return DataPacket
|
||||
*/
|
||||
public static function getPacketById(int $pid) : DataPacket{
|
||||
return static::$pool[$pid] ?? new UnknownPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $buffer
|
||||
* @return DataPacket
|
||||
*/
|
||||
public static function getPacket(string $buffer) : DataPacket{
|
||||
$pk = static::getPacketById(ord($buffer{0}));
|
||||
$pk->setBuffer($buffer);
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class PurchaseReceiptPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PURCHASE_RECEIPT_PACKET;
|
||||
|
||||
/** @var string[] */
|
||||
public $entries = [];
|
||||
|
||||
public function decodePayload(){
|
||||
$count = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->entries[] = $this->getString();
|
||||
}
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
$this->putString($entry);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePurchaseReceipt($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ShowStoreOfferPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET;
|
||||
|
||||
public $offerId;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->offerId = $this->getString();
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putString($this->offerId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleShowStoreOffer($this);
|
||||
}
|
||||
}
|
46
src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php
Normal file
46
src/pocketmine/network/mcpe/protocol/SimpleEventPacket.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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class SimpleEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET;
|
||||
|
||||
public $unknownShort1;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->unknownShort1 = $this->getLShort();
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putLShort($this->unknownShort1);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSimpleEvent($this);
|
||||
}
|
||||
}
|
@ -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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class StructureBlockUpdatePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::STRUCTURE_BLOCK_UPDATE_PACKET;
|
||||
|
||||
public function decodePayload(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleStructureBlockUpdate($this);
|
||||
}
|
||||
}
|
58
src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php
Normal file
58
src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class UpdateEquipPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET;
|
||||
|
||||
public $windowId;
|
||||
public $windowType;
|
||||
public $unknownVarint; //TODO: find out what this is (vanilla always sends 0)
|
||||
public $entityUniqueId;
|
||||
public $namedtag;
|
||||
|
||||
public function decodePayload(){
|
||||
$this->windowId = $this->getByte();
|
||||
$this->windowType = $this->getByte();
|
||||
$this->unknownVarint = $this->getVarInt();
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->namedtag = $this->get(true);
|
||||
}
|
||||
|
||||
public function encodePayload(){
|
||||
$this->putByte($this->windowId);
|
||||
$this->putByte($this->windowType);
|
||||
$this->putVarInt($this->unknownVarint);
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
$this->put($this->namedtag);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleUpdateEquip($this);
|
||||
}
|
||||
}
|
38
src/pocketmine/network/mcpe/protocol/types/ContainerIds.php
Normal file
38
src/pocketmine/network/mcpe/protocol/types/ContainerIds.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\types;
|
||||
|
||||
interface ContainerIds{
|
||||
|
||||
const NONE = -1;
|
||||
const INVENTORY = 0;
|
||||
const FIRST = 1;
|
||||
const LAST = 100;
|
||||
const OFFHAND = 119;
|
||||
const ARMOR = 120;
|
||||
const CREATIVE = 121;
|
||||
const HOTBAR = 122;
|
||||
const FIXED_INVENTORY = 123;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user