This commit is contained in:
Dylan K. Taylor 2017-06-04 16:54:25 +01:00
parent 138fb88431
commit 2b02fcfe2c
4 changed files with 17 additions and 9 deletions

View File

@ -355,4 +355,12 @@ abstract class DataPacket extends BinaryStream{
$this->putLFloat($y);
$this->putLFloat($z);
}
public function getByteRotation() : float{
return (float) ($this->getByte() * (360 / 256));
}
public function putByteRotation(float $rotation){
$this->putByte((int) ($rotation / (360 / 256)));
}
}

View File

@ -33,7 +33,7 @@ class MobEquipmentPacket extends DataPacket{
public $item;
public $inventorySlot;
public $hotbarSlot;
public $unknownByte;
public $unknownByte = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();

View File

@ -42,9 +42,9 @@ class MoveEntityPacket extends DataPacket{
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getByte() * (360.0 / 256);
$this->headYaw = $this->getByte() * (360.0 / 256);
$this->yaw = $this->getByte() * (360.0 / 256);
$this->pitch = $this->getByteRotation();
$this->headYaw = $this->getByteRotation();
$this->yaw = $this->getByteRotation();
$this->onGround = $this->getBool();
$this->teleported = $this->getBool();
}
@ -53,9 +53,9 @@ class MoveEntityPacket extends DataPacket{
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putByte($this->pitch / (360.0 / 256));
$this->putByte($this->headYaw / (360.0 / 256));
$this->putByte($this->yaw / (360.0 / 256));
$this->putByteRotation($this->pitch);
$this->putByteRotation($this->headYaw);
$this->putByteRotation($this->yaw);
$this->putBool($this->onGround);
$this->putBool($this->teleported);
}

View File

@ -178,11 +178,11 @@ class BinaryStream{
$this->buffer .= Binary::writeLTriad($v);
}
public function getByte(){
public function getByte() : int{
return ord($this->buffer{$this->offset++});
}
public function putByte($v){
public function putByte(int $v){
$this->buffer .= chr($v);
}