mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
more tweaks
This commit is contained in:
parent
6c08b74394
commit
426728342f
3 changed files with 23 additions and 14 deletions
|
|
@ -1152,9 +1152,10 @@ class Player{
|
|||
}
|
||||
public function addEntityMovementUpdateToQueue(Entity $e){
|
||||
$len = 0;
|
||||
$packets = 1;
|
||||
$packets = 0;
|
||||
$motionSent = false;
|
||||
$moveSent = false;
|
||||
$headSent = false;
|
||||
if($e->speedX != 0 || $e->speedY != 0 || $e->speedZ != 0){
|
||||
$motion = new SetEntityMotionPacket();
|
||||
$motion->eid = $e->eid;
|
||||
|
|
@ -1179,15 +1180,20 @@ class Player{
|
|||
++$packets;
|
||||
$moveSent = true;
|
||||
}
|
||||
if($e->headYaw != $e->lastHeadYaw){
|
||||
$headyaw = new RotateHeadPacket();
|
||||
$headyaw->eid = $e->eid;
|
||||
$headyaw->yaw = $e->headYaw;
|
||||
$headyaw->encode();
|
||||
$len += strlen($headyaw->buffer) + 1;
|
||||
++$packets;
|
||||
$headSent = true;
|
||||
}
|
||||
if($packets <= 0) return;
|
||||
|
||||
$headyaw = new RotateHeadPacket();
|
||||
$headyaw->eid = $e->eid;
|
||||
$headyaw->yaw = $e->headYaw;
|
||||
$headyaw->encode();
|
||||
|
||||
$len = strlen($headyaw->buffer) + 1;
|
||||
$MTU = $this->MTU - 24;
|
||||
if(($this->entityMovementQueueLength + $len) >= $MTU){
|
||||
console("force send");
|
||||
$this->sendEntityMovementUpdateQueue();
|
||||
}
|
||||
if($motionSent){
|
||||
|
|
@ -1200,9 +1206,11 @@ class Player{
|
|||
$move->reliability = 2;
|
||||
$this->entityMovementQueue->data[] = $move;
|
||||
}
|
||||
$headyaw->messageIndex = $this->counter[3]++;
|
||||
$headyaw->reliability = 2;
|
||||
$this->entityMovementQueue->data[] = $headyaw;
|
||||
if($headSent){
|
||||
$headyaw->messageIndex = $this->counter[3]++;
|
||||
$headyaw->reliability = 2;
|
||||
$this->entityMovementQueue->data[] = $headyaw;
|
||||
}
|
||||
|
||||
$this->entityMovementQueueLength += 6*$packets + $len;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,10 +621,10 @@ class Entity extends Position
|
|||
$this->onGround = $support;
|
||||
|
||||
|
||||
if($this->hasGravity){
|
||||
$this->speedY -= $this->inWater ? 0.02 : ($this->gravity); // TODO: replace with $gravity
|
||||
if($this->hasGravity){ //TODO causes setEntityMotion packet flood, fix
|
||||
$this->speedY -= $this->inWater ? 0.02 : ($this->gravity);
|
||||
$update = true;
|
||||
} elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
||||
}elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
||||
// $this->speedX = 0;
|
||||
// $this->speedY = 0;
|
||||
// $this->speedZ = 0;
|
||||
|
|
@ -1238,7 +1238,7 @@ class Entity extends Position
|
|||
$this->last[3] = $this->yaw;
|
||||
$this->last[4] = $this->pitch;
|
||||
$this->last[5] = microtime(true);
|
||||
$this->lastHeadYaw = $this->headYaw;
|
||||
//$this->lastHeadYaw = $this->headYaw;
|
||||
}
|
||||
|
||||
public function getPosition($round = false)
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ class MobController
|
|||
}
|
||||
|
||||
public function rotateTick(){ //TODO handle more rotation
|
||||
$this->entity->lastHeadYaw = $this->entity->headYaw;
|
||||
$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
||||
$w180min = min(abs($w180), 20)*Utils::getSign($w180);
|
||||
$this->entity->headYaw = Utils::wrapAngleTo360($this->entity->headYaw + $w180min);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue