Typehinted things in BinaryStream, sorted some methods and related bugfixes

This commit is contained in:
Dylan K. Taylor
2017-06-07 13:53:10 +01:00
parent e18a3ac933
commit 78c09267e5
10 changed files with 162 additions and 136 deletions

View File

@ -46,7 +46,7 @@ class BatchPacket extends DataPacket{
}
public function decode(){
$this->payload = $this->get(true);
$this->payload = $this->get(0);
}
public function encode(){

View File

@ -38,7 +38,7 @@ class BlockEntityDataPacket extends DataPacket{
public function decode(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->namedtag = $this->get(true);
$this->namedtag = $this->get(0);
}
public function encode(){

View File

@ -49,7 +49,7 @@ class CommandStepPacket extends DataPacket{
$this->inputJson = json_decode($this->getString());
$this->outputJson = json_decode($this->getString());
$this->get(true); //TODO: read command origin data
$this->get(0); //TODO: read command origin data
}
public function encode(){

View File

@ -117,7 +117,7 @@ abstract class DataPacket extends BinaryStream{
$value = $this->getByte();
break;
case Entity::DATA_TYPE_SHORT:
$value = $this->getLShort(true); //signed
$value = $this->getSignedLShort();
break;
case Entity::DATA_TYPE_INT:
$value = $this->getVarInt();

View File

@ -38,8 +38,8 @@ class MoveEntityPacket extends DataPacket{
public $yaw;
public $headYaw;
public $pitch;
public $onGround;
public $teleported;
public $onGround = false;
public $teleported = false;
public function decode(){
$this->entityRuntimeId = $this->getEntityRuntimeId();

View File

@ -47,13 +47,13 @@ class StartGamePacket extends DataPacket{
public $spawnX;
public $spawnY;
public $spawnZ;
public $hasAchievementsDisabled = 1;
public $hasAchievementsDisabled = true;
public $dayCycleStopTime = -1; //-1 = not stopped, any positive value = stopped at that time
public $eduMode = 0;
public $eduMode = false;
public $rainLevel;
public $lightningLevel;
public $commandsEnabled;
public $isTexturePacksRequired = 0;
public $isTexturePacksRequired = true;
public $levelId = ""; //base64 string, usually the same as world folder name in vanilla
public $worldName;
public $premiumWorldTemplateId = "";

View File

@ -45,7 +45,7 @@ class UnknownPacket extends DataPacket{
public function decode(){
$this->offset -= 1; //Rewind one byte so we can read the PID
$this->payload = $this->get(true);
$this->payload = $this->get(0);
}
public function encode(){

View File

@ -53,7 +53,7 @@ class UpdateTradePacket extends DataPacket{
$this->traderEid = $this->getEntityUniqueId();
$this->playerEid = $this->getEntityUniqueId();
$this->displayName = $this->getString();
$this->offers = $this->get(true);
$this->offers = $this->get(0);
}
public function encode(){