mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Merge branch 'stable'
This commit is contained in:
commit
9c06c1a06f
@ -316,10 +316,16 @@ class CrashDump{
|
||||
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*/
|
||||
public function addLine($line = "") : void{
|
||||
fwrite($this->fp, $line . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
*/
|
||||
public function add($str) : void{
|
||||
fwrite($this->fp, $str);
|
||||
}
|
||||
|
@ -161,6 +161,13 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
$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{
|
||||
if($entry instanceof ShapelessRecipe){
|
||||
return self::writeShapelessRecipe($entry, $stream, $pos);
|
||||
|
@ -119,10 +119,17 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function __get($name){
|
||||
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($name, $value){
|
||||
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
|
||||
}
|
||||
|
@ -73,6 +73,11 @@ final class Filesystem{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function cleanPath($path){
|
||||
$result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);
|
||||
|
||||
|
@ -223,6 +223,12 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
$this->notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $level
|
||||
* @param string $prefix
|
||||
* @param string $color
|
||||
*/
|
||||
protected function send($message, $level, $prefix, $color) : void{
|
||||
$time = new \DateTime('now', new \DateTimeZone($this->timezone));
|
||||
|
||||
|
@ -119,6 +119,9 @@ final class Process{
|
||||
return count(ThreadManager::getInstance()->getAll()) + 3; //RakLib + MainLogger + Main Thread
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pid
|
||||
*/
|
||||
public static function kill($pid) : void{
|
||||
$logger = \GlobalLogger::get();
|
||||
if($logger instanceof MainLogger){
|
||||
|
@ -25,7 +25,14 @@ namespace pocketmine\utils;
|
||||
|
||||
class ReversePriorityQueue extends \SplPriorityQueue{
|
||||
|
||||
/**
|
||||
* @param mixed $priority1
|
||||
* @param mixed $priority2
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compare($priority1, $priority2){
|
||||
//TODO: this will crash if non-numeric priorities are used
|
||||
return (int) -($priority1 - $priority2);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ class ServerKiller extends Thread{
|
||||
/** @var bool */
|
||||
private $stopped = false;
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
public function __construct($time = 15){
|
||||
$this->time = $time;
|
||||
}
|
||||
|
@ -66,18 +66,29 @@ abstract class BiomeSelector{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $z
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTemperature($x, $z){
|
||||
return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $z
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getRainfall($x, $z){
|
||||
return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: not sure on types here
|
||||
* @param int|float $x
|
||||
* @param int|float $z
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
|
@ -33,10 +33,33 @@ use function assert;
|
||||
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){
|
||||
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){
|
||||
$dx1 = (($x2 - $x) / ($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){
|
||||
$dx1 = (($x2 - $x) / ($x2 - $x1));
|
||||
$dx2 = (($x - $x1) / ($x2 - $x1));
|
||||
@ -82,10 +126,30 @@ abstract class Noise{
|
||||
$this->expansion = $expansion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $z
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
abstract public function getNoise2D($x, $z);
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $z
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
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){
|
||||
$result = 0;
|
||||
$amp = 1;
|
||||
@ -109,6 +173,14 @@ abstract class Noise{
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $z
|
||||
* @param bool $normalized
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function noise3D($x, $y, $z, $normalized = false){
|
||||
$result = 0;
|
||||
$amp = 1;
|
||||
|
@ -209,6 +209,12 @@ class Simplex extends Noise{
|
||||
return 32.0 * $n;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getNoise2D($x, $y){
|
||||
$x += $this->offsetX;
|
||||
$y += $this->offsetY;
|
||||
|
@ -7,6 +7,6 @@ parameters:
|
||||
rules:
|
||||
- PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule
|
||||
- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule
|
||||
#- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule
|
||||
- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule
|
||||
#- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule
|
||||
- PHPStan\Rules\Properties\MissingPropertyTypehintRule
|
||||
|
Loading…
x
Reference in New Issue
Block a user