Merge branch 'next-minor'

This commit is contained in:
Dylan K. Taylor 2019-05-02 15:07:38 +01:00
commit 0317b0f22d
2 changed files with 10 additions and 2 deletions

View File

@ -227,6 +227,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
throw new \InvalidStateException("Cannot create entities in unloaded chunks"); throw new \InvalidStateException("Cannot create entities in unloaded chunks");
} }
$this->motion = new Vector3(0, 0, 0);
if($nbt->hasTag("Motion", ListTag::class)){ if($nbt->hasTag("Motion", ListTag::class)){
/** @var float[] $motion */ /** @var float[] $motion */
$motion = $nbt->getListTag("Motion")->getAllValues(); $motion = $nbt->getListTag("Motion")->getAllValues();

View File

@ -111,6 +111,8 @@ use function trim;
use const INT32_MAX; use const INT32_MAX;
use const INT32_MIN; use const INT32_MIN;
use const M_PI; use const M_PI;
use const PHP_INT_MAX;
use const PHP_INT_MIN;
#include <rules/Level.h> #include <rules/Level.h>
@ -706,7 +708,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function sendTime(Player ...$targets){ public function sendTime(Player ...$targets){
$pk = new SetTimePacket(); $pk = new SetTimePacket();
$pk->time = $this->time; $pk->time = $this->time & 0xffffffff; //avoid overflowing the field, since the packet uses an int32
if(empty($targets)){ if(empty($targets)){
$this->broadcastGlobalPacket($pk); $this->broadcastGlobalPacket($pk);
@ -742,7 +744,12 @@ class Level implements ChunkManager, Metadatable{
protected function actuallyDoTick(int $currentTick) : void{ protected function actuallyDoTick(int $currentTick) : void{
if(!$this->stopTime){ if(!$this->stopTime){
$this->time++; //this simulates an overflow, as would happen in any language which doesn't do stupid things to var types
if($this->time === PHP_INT_MAX){
$this->time = PHP_INT_MIN;
}else{
$this->time++;
}
} }
$this->sunAnglePercentage = $this->computeSunAnglePercentage(); //Sun angle depends on the current time $this->sunAnglePercentage = $this->computeSunAnglePercentage(); //Sun angle depends on the current time