mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +00:00
fixed #992
This commit is contained in:
parent
138fb88431
commit
2b02fcfe2c
@ -355,4 +355,12 @@ abstract class DataPacket extends BinaryStream{
|
|||||||
$this->putLFloat($y);
|
$this->putLFloat($y);
|
||||||
$this->putLFloat($z);
|
$this->putLFloat($z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getByteRotation() : float{
|
||||||
|
return (float) ($this->getByte() * (360 / 256));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function putByteRotation(float $rotation){
|
||||||
|
$this->putByte((int) ($rotation / (360 / 256)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class MobEquipmentPacket extends DataPacket{
|
|||||||
public $item;
|
public $item;
|
||||||
public $inventorySlot;
|
public $inventorySlot;
|
||||||
public $hotbarSlot;
|
public $hotbarSlot;
|
||||||
public $unknownByte;
|
public $unknownByte = 0;
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
$this->eid = $this->getEntityRuntimeId();
|
$this->eid = $this->getEntityRuntimeId();
|
||||||
|
@ -42,9 +42,9 @@ class MoveEntityPacket extends DataPacket{
|
|||||||
public function decode(){
|
public function decode(){
|
||||||
$this->eid = $this->getEntityRuntimeId();
|
$this->eid = $this->getEntityRuntimeId();
|
||||||
$this->getVector3f($this->x, $this->y, $this->z);
|
$this->getVector3f($this->x, $this->y, $this->z);
|
||||||
$this->pitch = $this->getByte() * (360.0 / 256);
|
$this->pitch = $this->getByteRotation();
|
||||||
$this->headYaw = $this->getByte() * (360.0 / 256);
|
$this->headYaw = $this->getByteRotation();
|
||||||
$this->yaw = $this->getByte() * (360.0 / 256);
|
$this->yaw = $this->getByteRotation();
|
||||||
$this->onGround = $this->getBool();
|
$this->onGround = $this->getBool();
|
||||||
$this->teleported = $this->getBool();
|
$this->teleported = $this->getBool();
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ class MoveEntityPacket extends DataPacket{
|
|||||||
$this->reset();
|
$this->reset();
|
||||||
$this->putEntityRuntimeId($this->eid);
|
$this->putEntityRuntimeId($this->eid);
|
||||||
$this->putVector3f($this->x, $this->y, $this->z);
|
$this->putVector3f($this->x, $this->y, $this->z);
|
||||||
$this->putByte($this->pitch / (360.0 / 256));
|
$this->putByteRotation($this->pitch);
|
||||||
$this->putByte($this->headYaw / (360.0 / 256));
|
$this->putByteRotation($this->headYaw);
|
||||||
$this->putByte($this->yaw / (360.0 / 256));
|
$this->putByteRotation($this->yaw);
|
||||||
$this->putBool($this->onGround);
|
$this->putBool($this->onGround);
|
||||||
$this->putBool($this->teleported);
|
$this->putBool($this->teleported);
|
||||||
}
|
}
|
||||||
|
@ -178,11 +178,11 @@ class BinaryStream{
|
|||||||
$this->buffer .= Binary::writeLTriad($v);
|
$this->buffer .= Binary::writeLTriad($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getByte(){
|
public function getByte() : int{
|
||||||
return ord($this->buffer{$this->offset++});
|
return ord($this->buffer{$this->offset++});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function putByte($v){
|
public function putByte(int $v){
|
||||||
$this->buffer .= chr($v);
|
$this->buffer .= chr($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user