mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Use SetLocalPlayerAsInitializedPacket for spawning, fixed a bunch of bugs
this should fix forms not working during PlayerJoinEvent, and also removes the spurious PlayerItemHeldEvent firing on spawn bug. The player MUST now send this packet. Bots take note.
This commit is contained in:
@ -317,12 +317,13 @@ class NetworkSession{
|
||||
$this->setHandler(new PreSpawnSessionHandler($this->server, $this->player, $this));
|
||||
}
|
||||
|
||||
public function onSpawn() : void{
|
||||
public function onTerrainReady() : void{
|
||||
$pk = new PlayStatusPacket();
|
||||
$pk->status = PlayStatusPacket::PLAYER_SPAWN;
|
||||
$this->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
//TODO: split this up even further
|
||||
public function onSpawn() : void{
|
||||
$this->setHandler(new SimpleSessionHandler($this->player));
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\Player;
|
||||
@ -96,4 +97,10 @@ class PreSpawnSessionHandler extends SessionHandler{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
$this->player->doFirstSpawn();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
@ -402,8 +401,4 @@ class SimpleSessionHandler extends SessionHandler{
|
||||
public function handleLabTable(LabTablePacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user