Fix DisconnectionScreen, add getBool() and putBool() methods, update some packets

This commit is contained in:
Dylan K. Taylor 2016-10-12 14:14:30 +01:00
parent ec328a8160
commit df88e9272e
13 changed files with 28 additions and 15 deletions

View File

@ -44,7 +44,7 @@ class ChangeDimensionPacket extends DataPacket{
$this->reset();
$this->putVarInt($this->dimension);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putByte($this->unknown);
$this->putBool($this->unknown);
}
}

View File

@ -163,7 +163,7 @@ class CraftingDataPacket extends DataPacket{
$writer->reset();
}
$this->putByte($this->cleanRecipes ? 1 : 0);
$this->putBool($this->cleanRecipes);
}
}

View File

@ -27,14 +27,17 @@ namespace pocketmine\network\protocol;
class DisconnectPacket extends DataPacket{
const NETWORK_ID = Info::DISCONNECT_PACKET;
public $hideDisconnectionScreen = false;
public $message;
public function decode(){
$this->hideDisconnectionScreen = $this->getBool();
$this->message = $this->getString();
}
public function encode(){
$this->reset();
$this->putBool($this->hideDisconnectionScreen);
$this->putString($this->message);
}

View File

@ -44,6 +44,6 @@ class LevelSoundEventPacket extends DataPacket{
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->volume);
$this->putVarInt($this->pitch);
$this->putByte($this->unknownBool);
$this->putBool($this->unknownBool);
}
}

View File

@ -48,7 +48,7 @@ class MobEffectPacket extends DataPacket{
$this->putByte($this->eventId);
$this->putVarInt($this->effectId);
$this->putVarInt($this->amplifier);
$this->putByte($this->particles);
$this->putBool($this->particles);
$this->putVarInt($this->duration);
}

View File

@ -53,7 +53,7 @@ class MovePlayerPacket extends DataPacket{
$this->yaw = $this->getLFloat();
$this->bodyYaw = $this->getLFloat();
$this->mode = $this->getByte();
$this->onGround = $this->getByte() > 0;
$this->onGround = $this->getBool();
}
public function encode(){
@ -64,7 +64,7 @@ class MovePlayerPacket extends DataPacket{
$this->putLFloat($this->yaw);
$this->putLFloat($this->bodyYaw); //TODO
$this->putByte($this->mode);
$this->putByte($this->onGround > 0);
$this->putBool($this->onGround);
}
}

View File

@ -35,8 +35,8 @@ class PlayerInputPacket extends DataPacket{
public function decode(){
$this->motionX = $this->getLFloat();
$this->motionY = $this->getLFloat();
$this->unknownBool1 = $this->getByte();
$this->unknownBool2 = $this->getByte();
$this->unknownBool1 = $this->getBool();
$this->unknownBool2 = $this->getBool();
}
public function encode(){

View File

@ -40,7 +40,7 @@ class ResourcePacksInfoPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putByte($this->mustAccept);
$this->putBool($this->mustAccept);
$this->putShort(count($this->behaviourPackEntries));
foreach($this->behaviourPackEntries as $entry){
$this->putString($entry->getPackId());

View File

@ -35,7 +35,7 @@ class SetCommandsEnabledPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putByte($this->enabled);
$this->putBool($this->enabled);
}
}

View File

@ -31,6 +31,7 @@ class SetSpawnPositionPacket extends DataPacket{
public $x;
public $y;
public $z;
public $unknownBool;
public function decode(){
@ -40,6 +41,7 @@ class SetSpawnPositionPacket extends DataPacket{
$this->reset();
$this->putVarInt($this->unknown);
$this->putBlockCoords($this->x, $this->y, $this->z);
$this->putBool($this->unknownBool);
}
}

View File

@ -36,7 +36,7 @@ class SetTimePacket extends DataPacket{
public function encode(){
$this->reset();
$this->putVarInt($this->time);
$this->putByte((int) $this->started);
$this->putBool($this->started);
}
}

View File

@ -67,13 +67,13 @@ class StartGamePacket extends DataPacket{
$this->putVarInt($this->gamemode);
$this->putVarInt($this->difficulty);
$this->putBlockCoords($this->spawnX, $this->spawnY, $this->spawnZ);
$this->putByte($this->hasAchievementsDisabled);
$this->putBool($this->hasAchievementsDisabled);
$this->putVarInt($this->dayCycleStopTime);
$this->putByte($this->eduMode);
$this->putBool($this->eduMode);
$this->putLFloat($this->rainLevel);
$this->putLFloat($this->lightningLevel);
$this->putByte($this->commandsEnabled);
$this->putByte($this->isTexturePacksRequired);
$this->putBool($this->commandsEnabled);
$this->putBool($this->isTexturePacksRequired);
$this->putString($this->unknown);
$this->putString($this->worldName);
}

View File

@ -70,6 +70,14 @@ class BinaryStream extends \stdClass{
$this->buffer .= $str;
}
public function getBool() : bool{
return (bool) $this->getByte();
}
public function putBool($v){
$this->putByte((bool) $v);
}
public function getLong(){
return Binary::readLong($this->get(8));
}