skins fixed and added SetPlayerGameTypePacket

This commit is contained in:
Intyre 2015-11-26 00:47:58 +01:00
parent 2e5490fb5b
commit c803dd8e69
No known key found for this signature in database
GPG Key ID: B06D41D26935005A
6 changed files with 48 additions and 16 deletions

View File

@ -113,6 +113,7 @@ use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\network\protocol\PlayerActionPacket;
use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\RespawnPacket;
use pocketmine\network\protocol\SetPlayerGameTypePacket;
use pocketmine\network\protocol\TextPacket;
use pocketmine\network\protocol\MovePlayerPacket;
@ -1085,7 +1086,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return false;
}
$this->gamemode = $gm;
$this->allowFlight = $this->isCreative();
@ -1098,19 +1098,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode);
$spawnPosition = $this->getSpawn();
$pk = new StartGamePacket();
$pk->seed = -1;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->spawnX = (int) $spawnPosition->x;
$pk->spawnY = (int) $spawnPosition->y;
$pk->spawnZ = (int) $spawnPosition->z;
$pk->generator = 1; //0 old, 1 infinite, 2 flat
$pk = new SetPlayerGameTypePacket();
$pk->gamemode = $this->gamemode & 0x01;
$pk->eid = 0;
$this->dataPacket($pk);
$this->sendSettings();

View File

@ -74,6 +74,7 @@ use pocketmine\network\protocol\TakeItemEntityPacket;
use pocketmine\network\protocol\BlockEventPacket;
use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\protocol\UseItemPacket;
use pocketmine\network\protocol\SetPlayerGameTypePacket;
use pocketmine\network\protocol\PlayerListPacket;
use pocketmine\Player;
use pocketmine\Server;
@ -352,6 +353,7 @@ class Network{
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
$this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class);
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class);
}
}

View File

@ -83,7 +83,7 @@ interface Info{
const FULL_CHUNK_DATA_PACKET = 0xbf;
const SET_DIFFICULTY_PACKET = 0xc0;
//const CHANGE_DIMENSION_PACKET = 0xc1;
//const SET_PLAYER_GAMETYPE_PACKET = 0xc2;
const SET_PLAYER_GAMETYPE_PACKET = 0xc2;
const PLAYER_LIST_PACKET = 0xc3;
//const TELEMETRY_EVENT_PACKET = 0xc4;
//const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5

View File

@ -52,8 +52,8 @@ class LoginPacket extends DataPacket{
$this->serverAddress = $this->getString();
$this->clientSecret = $this->getString();
$this->getByte(); // TODO: skin transparency, experimental or not?
$this->slim = $this->getByte() > 0;
$this->getByte(); // TODO: skin transparency, experimental or not?
$this->skin = $this->getString();
}

View File

@ -53,8 +53,8 @@ class PlayerListPacket extends DataPacket{
$this->putUUID($d[0]);
$this->putLong($d[1]);
$this->putString($d[2]);
$this->putByte(0); // TODO: skin transparency, experimental or not?
$this->putByte($d[3] ? 1 : 0);
$this->putByte(0); // TODO: skin transparency, experimental or not?
$this->putString($d[4]);
}else{
$this->putUUID($d[0]);

View File

@ -0,0 +1,41 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class SetPlayerGameTypePacket extends DataPacket{
const NETWORK_ID = Info::SET_PLAYER_GAMETYPE_PACKET;
public $gamemode;
public function decode(){
}
public function encode(){
$this->reset();
$this->putInt($this->gamemode);
}
}