Merge remote-tracking branch 'origin/stable' into next-minor

This commit is contained in:
Dylan K. Taylor
2022-05-11 13:12:45 +01:00
10 changed files with 72 additions and 38 deletions

View File

@ -282,6 +282,7 @@ abstract class Entity{
public function setNameTagVisible(bool $value = true) : void{
$this->nameTagVisible = $value;
$this->networkPropertiesDirty = true;
}
public function setNameTagAlwaysVisible(bool $value = true) : void{

View File

@ -42,5 +42,9 @@ class Boat extends Item{
return 1200; //400 in PC
}
public function getMaxStackSize() : int{
return 1;
}
//TODO
}

View File

@ -59,6 +59,7 @@ use function interface_exists;
use function is_a;
use function is_array;
use function is_bool;
use function is_float;
use function is_infinite;
use function is_int;
use function is_nan;
@ -435,6 +436,19 @@ final class Utils{
return $lines;
}
private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{
return match(true){
is_object($value) => "object " . self::getNiceClassName($value) . "#" . spl_object_id($value),
is_array($value) => "array[" . count($value) . "]",
is_string($value) => "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength),
is_bool($value) => $value ? "true" : "false",
is_int($value) => "int " . $value,
is_float($value) => "float " . $value,
$value === null => "null",
default => gettype($value) . " " . Utils::printable((string) $value)
};
}
/**
* @param mixed[][] $trace
* @phpstan-param list<array<string, mixed>> $trace
@ -451,22 +465,15 @@ final class Utils{
}else{
$args = $trace[$i]["params"];
}
/** @var mixed[] $args */
$params = implode(", ", array_map(function($value) use($maxStringLength) : string{
if(is_object($value)){
return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value);
}
if(is_array($value)){
return "array[" . count($value) . "]";
}
if(is_string($value)){
return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength);
}
if(is_bool($value)){
return $value ? "true" : "false";
}
return gettype($value) . " " . Utils::printable((string) $value);
}, $args));
$paramsList = [];
$offset = 0;
foreach($args as $argId => $value){
$paramsList[] = ($argId === $offset ? "" : "$argId: ") . self::stringifyValueForTrace($value, $maxStringLength);
$offset++;
}
$params = implode(", ", $paramsList);
}
$messages[] = "#$i " . (isset($trace[$i]["file"]) ? Filesystem::cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" || $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")";
}

View File

@ -3004,9 +3004,14 @@ class World implements ChunkManager{
unset($this->activeChunkPopulationTasks[$index]);
if($dirtyChunks === 0){
$promise = $this->chunkPopulationRequestMap[$index];
unset($this->chunkPopulationRequestMap[$index]);
$promise->resolve($chunk);
$promise = $this->chunkPopulationRequestMap[$index] ?? null;
if($promise !== null){
unset($this->chunkPopulationRequestMap[$index]);
$promise->resolve($chunk);
}else{
//Handlers of ChunkPopulateEvent, ChunkLoadEvent, or just ChunkListeners can cause this
$this->logger->debug("Unable to resolve population promise for chunk x=$x,z=$z - populated chunk was forcibly unloaded while setting modified chunks");
}
}else{
//request failed, stick it back on the queue
//we didn't resolve the promise or touch it in any way, so any fake chunk loaders are still valid and