mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
fixed player posiiton on bed, hopefully fixed players not receiving packets sometimes
This commit is contained in:
parent
f93aa2601a
commit
4c072e91cd
4 changed files with 19 additions and 9 deletions
|
|
@ -274,9 +274,10 @@ class Player{
|
|||
$this->data->set("bed-position", $this->bedPosition);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @param Vector3 $pos position of the <b>top block</b> of the bed
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function sleepOn(Position $pos){
|
||||
|
|
@ -291,9 +292,14 @@ class Player{
|
|||
$this->setBedPosition($pos);
|
||||
$this->isSleeping = $pos;
|
||||
$this->sleepingTime = 0;
|
||||
$this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level), false, false, false, false);
|
||||
$meta = $this->level->level->getBlockDamage($pos->x, $pos->y, $pos->z);
|
||||
$xoff = BedBlock::PLAYER_BED_OFFS_X[$meta & 3];
|
||||
$zoff = BedBlock::PLAYER_BED_OFFS_Z[$meta & 3];
|
||||
$this->teleport(new Position($pos->x + $xoff, $pos->y + 0.9375, $pos->z + $zoff, $this->level), false, false, false, false);
|
||||
//TODO change player hitbox size after he starts sleeping
|
||||
if($this->entity instanceof Entity){
|
||||
$this->entity->forceUpdateMovement = true;
|
||||
$this->entity->updateMovement();
|
||||
$this->entity->updateMetadata();
|
||||
}
|
||||
|
||||
|
|
@ -3468,8 +3474,8 @@ class Player{
|
|||
$this->resendQueue[$count] =& $this->recoveryQueue[$count];
|
||||
$this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
|
||||
unset($this->recoveryQueue[$count]);
|
||||
}else{
|
||||
++$this->packetStats[1]; //lost and wont be recovered
|
||||
}else{ //lost and wont be recovered
|
||||
++$this->packetStats[1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class Entity extends Position
|
|||
const CLASS_TYPE = - 1;
|
||||
const MIN_POSSIBLE_SPEED = 1/8000; //anything below will send 0 to player
|
||||
|
||||
public $forceUpdateMovement = false;
|
||||
public $searchForClosestPlayers = false;
|
||||
public $modifySpeedY = false;
|
||||
public $modifedSpeedY = 0.0;
|
||||
|
|
@ -1029,7 +1030,8 @@ class Entity extends Position
|
|||
return false;
|
||||
}
|
||||
$now = microtime(true);
|
||||
if($this->isStatic === false and ($this->lastX != $this->x or $this->lastY != $this->y or $this->lastZ != $this->z or $this->lastYaw != $this->yaw or $this->lastPitch != $this->pitch or $this->lastHeadYaw != $this->headYaw)){
|
||||
if($this->isStatic === false && ($this->lastX != $this->x || $this->lastY != $this->y || $this->lastZ != $this->z || $this->lastYaw != $this->yaw || $this->lastPitch != $this->pitch || $this->lastHeadYaw != $this->headYaw || $this->forceUpdateMovement)){
|
||||
$this->forceUpdateMovement = false;
|
||||
if($this->class === ENTITY_PLAYER){
|
||||
if($this->server->api->handle("entity.move", $this) === false){
|
||||
if($this->class === ENTITY_PLAYER){
|
||||
|
|
@ -1043,7 +1045,7 @@ class Entity extends Position
|
|||
$pk = new MovePlayerPacket();
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->y = $this->y - 1 - ($this->player->isSleeping ? 0.7375 : 0);
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class BedBlock extends TransparentBlock{
|
|||
[0, -1],
|
||||
[1, 0]
|
||||
];
|
||||
const PLAYER_BED_OFFS_X = [0.5, 0.1, 0.5, 0.9];
|
||||
const PLAYER_BED_OFFS_Z = [0.9, 0.5, 0.1, 0.5];
|
||||
public function __construct($type = 0){
|
||||
parent::__construct(BED_BLOCK, $type, "Bed Block");
|
||||
$this->isActivable = true;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class Explosion{
|
|||
$pk->radius = $this->size;
|
||||
$pk->records = []; //ExplodePacket doesnt seem to use the records provided by this packet, so no need to send more data
|
||||
foreach ($this->level->players as $player){
|
||||
$player->blockQueueDataPacket($pk);
|
||||
$player->blockQueueDataPacket(clone $pk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ class Explosion{
|
|||
$pk->radius = $this->size;
|
||||
$pk->records = []; //ExplodePacket doesnt seem to use the records provided by this packet, so no need to send more data
|
||||
foreach ($this->level->players as $player){
|
||||
$player->blockQueueDataPacket($pk);
|
||||
$player->blockQueueDataPacket(clone $pk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue