Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor 2020-01-11 22:36:57 +00:00
commit 9c06c1a06f
12 changed files with 137 additions and 4 deletions

View File

@ -316,10 +316,16 @@ class CrashDump{
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS()); $this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
} }
/**
* @param string $line
*/
public function addLine($line = "") : void{ public function addLine($line = "") : void{
fwrite($this->fp, $line . PHP_EOL); fwrite($this->fp, $line . PHP_EOL);
} }
/**
* @param string $str
*/
public function add($str) : void{ public function add($str) : void{
fwrite($this->fp, $str); fwrite($this->fp, $str);
} }

View File

@ -161,6 +161,13 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
$this->cleanRecipes = $this->getBool(); $this->cleanRecipes = $this->getBool();
} }
/**
* @param object $entry
* @param NetworkBinaryStream $stream
* @param int $pos
*
* @return int
*/
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos) : int{ private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos) : int{
if($entry instanceof ShapelessRecipe){ if($entry instanceof ShapelessRecipe){
return self::writeShapelessRecipe($entry, $stream, $pos); return self::writeShapelessRecipe($entry, $stream, $pos);

View File

@ -119,10 +119,17 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
return $data; return $data;
} }
/**
* @param string $name
*/
public function __get($name){ public function __get($name){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
} }
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value){ public function __set($name, $value){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
} }

View File

@ -73,6 +73,11 @@ final class Filesystem{
} }
} }
/**
* @param string $path
*
* @return string
*/
public static function cleanPath($path){ public static function cleanPath($path){
$result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path); $result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);

View File

@ -223,6 +223,12 @@ class MainLogger extends \AttachableThreadedLogger{
$this->notify(); $this->notify();
} }
/**
* @param string $message
* @param string $level
* @param string $prefix
* @param string $color
*/
protected function send($message, $level, $prefix, $color) : void{ protected function send($message, $level, $prefix, $color) : void{
$time = new \DateTime('now', new \DateTimeZone($this->timezone)); $time = new \DateTime('now', new \DateTimeZone($this->timezone));

View File

@ -119,6 +119,9 @@ final class Process{
return count(ThreadManager::getInstance()->getAll()) + 3; //RakLib + MainLogger + Main Thread return count(ThreadManager::getInstance()->getAll()) + 3; //RakLib + MainLogger + Main Thread
} }
/**
* @param int $pid
*/
public static function kill($pid) : void{ public static function kill($pid) : void{
$logger = \GlobalLogger::get(); $logger = \GlobalLogger::get();
if($logger instanceof MainLogger){ if($logger instanceof MainLogger){

View File

@ -25,7 +25,14 @@ namespace pocketmine\utils;
class ReversePriorityQueue extends \SplPriorityQueue{ class ReversePriorityQueue extends \SplPriorityQueue{
/**
* @param mixed $priority1
* @param mixed $priority2
*
* @return int
*/
public function compare($priority1, $priority2){ public function compare($priority1, $priority2){
//TODO: this will crash if non-numeric priorities are used
return (int) -($priority1 - $priority2); return (int) -($priority1 - $priority2);
} }
} }

View File

@ -35,6 +35,9 @@ class ServerKiller extends Thread{
/** @var bool */ /** @var bool */
private $stopped = false; private $stopped = false;
/**
* @param int $time
*/
public function __construct($time = 15){ public function __construct($time = 15){
$this->time = $time; $this->time = $time;
} }

View File

@ -66,18 +66,29 @@ abstract class BiomeSelector{
} }
} }
/**
* @param float $x
* @param float $z
*
* @return float
*/
public function getTemperature($x, $z){ public function getTemperature($x, $z){
return ($this->temperature->noise2D($x, $z, true) + 1) / 2; return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
} }
/**
* @param float $x
* @param float $z
*
* @return float
*/
public function getRainfall($x, $z){ public function getRainfall($x, $z){
return ($this->rainfall->noise2D($x, $z, true) + 1) / 2; return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
} }
/** /**
* TODO: not sure on types here * @param int $x
* @param int|float $x * @param int $z
* @param int|float $z
* *
* @return Biome * @return Biome
*/ */

View File

@ -33,10 +33,33 @@ use function assert;
abstract class Noise{ abstract class Noise{
/**
* @param float $x
* @param float $x1
* @param float $x2
* @param float $q0
* @param float $q1
*
* @return float
*/
public static function linearLerp($x, $x1, $x2, $q0, $q1){ public static function linearLerp($x, $x1, $x2, $q0, $q1){
return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $q1; return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $q1;
} }
/**
* @param float $x
* @param float $y
* @param float $q00
* @param float $q01
* @param float $q10
* @param float $q11
* @param float $x1
* @param float $x2
* @param float $y1
* @param float $y2
*
* @return float
*/
public static function bilinearLerp($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2){ public static function bilinearLerp($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2){
$dx1 = (($x2 - $x) / ($x2 - $x1)); $dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($x2 - $x1)); $dx2 = (($x - $x1) / ($x2 - $x1));
@ -48,6 +71,27 @@ abstract class Noise{
); );
} }
/**
* @param float $x
* @param float $y
* @param float $z
* @param float $q000
* @param float $q001
* @param float $q010
* @param float $q011
* @param float $q100
* @param float $q101
* @param float $q110
* @param float $q111
* @param float $x1
* @param float $x2
* @param float $y1
* @param float $y2
* @param float $z1
* @param float $z2
*
* @return float
*/
public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2){ public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2){
$dx1 = (($x2 - $x) / ($x2 - $x1)); $dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($x2 - $x1)); $dx2 = (($x - $x1) / ($x2 - $x1));
@ -82,10 +126,30 @@ abstract class Noise{
$this->expansion = $expansion; $this->expansion = $expansion;
} }
/**
* @param float $x
* @param float $z
*
* @return float
*/
abstract public function getNoise2D($x, $z); abstract public function getNoise2D($x, $z);
/**
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
abstract public function getNoise3D($x, $y, $z); abstract public function getNoise3D($x, $y, $z);
/**
* @param float $x
* @param float $z
* @param bool $normalized
*
* @return float
*/
public function noise2D($x, $z, $normalized = false){ public function noise2D($x, $z, $normalized = false){
$result = 0; $result = 0;
$amp = 1; $amp = 1;
@ -109,6 +173,14 @@ abstract class Noise{
return $result; return $result;
} }
/**
* @param float $x
* @param float $y
* @param float $z
* @param bool $normalized
*
* @return float
*/
public function noise3D($x, $y, $z, $normalized = false){ public function noise3D($x, $y, $z, $normalized = false){
$result = 0; $result = 0;
$amp = 1; $amp = 1;

View File

@ -209,6 +209,12 @@ class Simplex extends Noise{
return 32.0 * $n; return 32.0 * $n;
} }
/**
* @param float $x
* @param float $y
*
* @return float
*/
public function getNoise2D($x, $y){ public function getNoise2D($x, $y){
$x += $this->offsetX; $x += $this->offsetX;
$y += $this->offsetY; $y += $this->offsetY;

View File

@ -7,6 +7,6 @@ parameters:
rules: rules:
- PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule
- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule - PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule
#- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule - PHPStan\Rules\Methods\MissingMethodParameterTypehintRule
#- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule #- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule
- PHPStan\Rules\Properties\MissingPropertyTypehintRule - PHPStan\Rules\Properties\MissingPropertyTypehintRule