Merge branch 'stable' into minor-next

This commit is contained in:
Dylan K. Taylor 2023-07-24 12:02:24 +01:00
commit 3afe3b7f44
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
18 changed files with 71 additions and 29 deletions

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup PHP and tools - name: Setup PHP and tools
uses: shivammathur/setup-php@2.25.2 uses: shivammathur/setup-php@2.25.4
with: with:
php-version: 8.1 php-version: 8.1

View File

@ -18,7 +18,7 @@ jobs:
submodules: true submodules: true
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@2.25.2 uses: shivammathur/setup-php@2.25.4
with: with:
php-version: 8.1 php-version: 8.1

View File

@ -173,7 +173,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup PHP and tools - name: Setup PHP and tools
uses: shivammathur/setup-php@2.25.2 uses: shivammathur/setup-php@2.25.4
with: with:
php-version: 8.1 php-version: 8.1
tools: php-cs-fixer:3.17 tools: php-cs-fixer:3.17

@ -1 +1 @@
Subproject commit e0c918d1379465964acefd562d9e48f87cfc2c9e Subproject commit 46604f2f6a07e3f68a82e4f4d7efdd45629b101e

13
composer.lock generated
View File

@ -2546,16 +2546,16 @@
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "6.0.0", "version": "6.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "aab257c712de87b90194febd52e4d184551c2d44" "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/aab257c712de87b90194febd52e4d184551c2d44", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4",
"reference": "aab257c712de87b90194febd52e4d184551c2d44", "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2595,7 +2595,8 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/6.0.0" "security": "https://github.com/sebastianbergmann/global-state/security/policy",
"source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1"
}, },
"funding": [ "funding": [
{ {
@ -2603,7 +2604,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-02-03T07:07:38+00:00" "time": "2023-07-19T07:19:23+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",

View File

@ -341,7 +341,7 @@ JIT_WARNING
if(ThreadManager::getInstance()->stopAll() > 0){ if(ThreadManager::getInstance()->stopAll() > 0){
$logger->debug("Some threads could not be stopped, performing a force-kill"); $logger->debug("Some threads could not be stopped, performing a force-kill");
Process::kill(Process::pid(), true); Process::kill(Process::pid());
} }
}while(false); }while(false);

View File

@ -1427,7 +1427,7 @@ class Server{
private function forceShutdownExit() : void{ private function forceShutdownExit() : void{
$this->forceShutdown(); $this->forceShutdown();
Process::kill(Process::pid(), true); Process::kill(Process::pid());
} }
public function forceShutdown() : void{ public function forceShutdown() : void{
@ -1495,7 +1495,7 @@ class Server{
}catch(\Throwable $e){ }catch(\Throwable $e){
$this->logger->logException($e); $this->logger->logException($e);
$this->logger->emergency("Crashed while crashing, killing process"); $this->logger->emergency("Crashed while crashing, killing process");
@Process::kill(Process::pid(), true); @Process::kill(Process::pid());
} }
} }
@ -1649,7 +1649,7 @@ class Server{
echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL; echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL;
sleep($spacing); sleep($spacing);
} }
@Process::kill(Process::pid(), true); @Process::kill(Process::pid());
exit(1); exit(1);
} }

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockBurnEvent; use pocketmine\event\block\BlockBurnEvent;
use pocketmine\event\block\BlockSpreadEvent; use pocketmine\event\block\BlockSpreadEvent;
@ -58,12 +59,16 @@ class Fire extends BaseFire{
return 1; return 1;
} }
private function canBeSupportedBy(Block $block) : bool{
return $block->getSupportType(Facing::UP)->equals(SupportType::FULL());
}
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
$world = $this->position->getWorld(); $world = $this->position->getWorld();
$down = $this->getSide(Facing::DOWN); $down = $this->getSide(Facing::DOWN);
if(SoulFire::canBeSupportedBy($down)){ if(SoulFire::canBeSupportedBy($down)){
$world->setBlock($this->position, VanillaBlocks::SOUL_FIRE()); $world->setBlock($this->position, VanillaBlocks::SOUL_FIRE());
}elseif($down->isTransparent() && !$this->hasAdjacentFlammableBlocks()){ }elseif(!$this->canBeSupportedBy($this->getSide(Facing::DOWN)) && !$this->hasAdjacentFlammableBlocks()){
$world->setBlock($this->position, VanillaBlocks::AIR()); $world->setBlock($this->position, VanillaBlocks::AIR());
}else{ }else{
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40)); $world->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40));

View File

@ -48,12 +48,7 @@ class FrostedIce extends Ice{
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
$world = $this->position->getWorld(); $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
if(!$this->checkAdjacentBlocks(2)){
$world->useBreakOn($this->position);
}else{
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
}
} }
public function onRandomTick() : void{ public function onRandomTick() : void{

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\ShulkerBox as TileShulkerBox; use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
use pocketmine\block\utils\AnyFacingTrait; use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -110,4 +111,8 @@ class ShulkerBox extends Opaque{
return true; return true;
} }
public function getSupportType(int $facing) : SupportType{
return SupportType::NONE();
}
} }

View File

@ -53,7 +53,7 @@ class KillCommand extends VanillaCommand{
return true; return true;
} }
$player->attack(new EntityDamageEvent($player, EntityDamageEvent::CAUSE_SUICIDE, 1000)); $player->attack(new EntityDamageEvent($player, EntityDamageEvent::CAUSE_SUICIDE, $player->getHealth()));
if($player === $sender){ if($player === $sender){
$sender->sendMessage(KnownTranslationFactory::commands_kill_successful($sender->getName())); $sender->sendMessage(KnownTranslationFactory::commands_kill_successful($sender->getName()));
}else{ }else{

View File

@ -94,4 +94,4 @@ while(!feof($socket)){
//For simplicity's sake, we don't bother with a graceful shutdown here. //For simplicity's sake, we don't bother with a graceful shutdown here.
//The parent process would normally forcibly terminate the child process anyway, so we only reach this point if the //The parent process would normally forcibly terminate the child process anyway, so we only reach this point if the
//parent process was terminated forcibly and didn't clean up after itself. //parent process was terminated forcibly and didn't clean up after itself.
Process::kill(Process::pid(), false); Process::kill(Process::pid());

View File

@ -520,7 +520,9 @@ abstract class Living extends Entity{
$source->cancel(); $source->cancel();
} }
if($source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE){
$this->applyDamageModifiers($source); $this->applyDamageModifiers($source);
}
if($source instanceof EntityDamageByEntityEvent && ( if($source instanceof EntityDamageByEntityEvent && (
$source->getCause() === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION || $source->getCause() === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION ||

View File

@ -139,6 +139,6 @@ final class StandardEntityEventBroadcaster implements EntityEventBroadcaster{
} }
public function onEmote(array $recipients, Human $from, string $emoteId) : void{ public function onEmote(array $recipients, Human $from, string $emoteId) : void{
$this->sendDataPacket($recipients, EmotePacket::create($from->getId(), $emoteId, "", "", EmotePacket::FLAG_SERVER)); $this->sendDataPacket($recipients, EmotePacket::create($from->getId(), $emoteId, "", "", EmotePacket::FLAG_SERVER | EmotePacket::FLAG_MUTE_ANNOUNCEMENT));
} }
} }

View File

@ -30,7 +30,7 @@ use const M_SQRT2;
final class ChunkSelector{ final class ChunkSelector{
/** /**
* @preturn \Generator|int[] * @return \Generator|int[]
* @phpstan-return \Generator<int, int, void, void> * @phpstan-return \Generator<int, int, void, void>
*/ */
public function selectChunks(int $radius, int $centerX, int $centerZ) : \Generator{ public function selectChunks(int $radius, int $centerX, int $centerZ) : \Generator{

View File

@ -125,7 +125,10 @@ final class Process{
return count(ThreadManager::getInstance()->getAll()) + 2; //MainLogger + Main Thread return count(ThreadManager::getInstance()->getAll()) + 2; //MainLogger + Main Thread
} }
public static function kill(int $pid, bool $subprocesses) : void{ /**
* @param bool $subprocesses @deprecated
*/
public static function kill(int $pid, bool $subprocesses = false) : void{
$logger = \GlobalLogger::get(); $logger = \GlobalLogger::get();
if($logger instanceof MainLogger){ if($logger instanceof MainLogger){
$logger->syncFlushBuffer(); $logger->syncFlushBuffer();

View File

@ -42,7 +42,7 @@ class ServerKiller extends Thread{
}); });
if(time() - $start >= $this->time){ if(time() - $start >= $this->time){
echo "\nTook too long to stop, server was killed forcefully!\n"; echo "\nTook too long to stop, server was killed forcefully!\n";
@Process::kill(Process::pid(), true); @Process::kill(Process::pid());
} }
} }

View File

@ -27,6 +27,7 @@ use pocketmine\block\Block;
use pocketmine\data\bedrock\BiomeIds; use pocketmine\data\bedrock\BiomeIds;
use pocketmine\data\bedrock\block\BlockStateDeserializeException; use pocketmine\data\bedrock\block\BlockStateDeserializeException;
use pocketmine\nbt\LittleEndianNbtSerializer; use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NBT;
use pocketmine\nbt\NbtDataException; use pocketmine\nbt\NbtDataException;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\TreeRoot; use pocketmine\nbt\TreeRoot;
@ -155,7 +156,33 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
$nbt = new LittleEndianNbtSerializer(); $nbt = new LittleEndianNbtSerializer();
$palette = []; $palette = [];
$paletteSize = $bitsPerBlock === 0 ? 1 : $stream->getLInt(); if($bitsPerBlock === 0){
$paletteSize = 1;
/*
* Due to code copy-paste in a public plugin, some PM4 worlds have 0 bpb palettes with a length prefix.
* This is invalid and does not happen in vanilla.
* These palettes were accepted by PM4 despite being invalid, but PM5 considered them corrupt, causing loss
* of data. Since many users were affected by this, a workaround is therefore necessary to allow PM5 to read
* these worlds without data loss.
*
* References:
* - https://github.com/Refaltor77/CustomItemAPI/issues/68
* - https://github.com/pmmp/PocketMine-MP/issues/5911
*/
$offset = $stream->getOffset();
$byte1 = $stream->getByte();
$stream->setOffset($offset); //reset offset
if($byte1 !== NBT::TAG_Compound){ //normally the first byte would be the NBT of the blockstate
$susLength = $stream->getLInt();
if($susLength !== 1){ //make sure the data isn't complete garbage
throw new CorruptedChunkException("CustomItemAPI borked 0 bpb palette should always have a length of 1");
}
$logger->error("Unexpected palette size for 0 bpb palette");
}
}else{
$paletteSize = $stream->getLInt();
}
for($i = 0; $i < $paletteSize; ++$i){ for($i = 0; $i < $paletteSize; ++$i){
try{ try{
@ -276,6 +303,10 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
$previous = $decoded; $previous = $decoded;
if($nextIndex <= Chunk::MAX_SUBCHUNK_INDEX){ //older versions wrote additional superfluous biome palettes if($nextIndex <= Chunk::MAX_SUBCHUNK_INDEX){ //older versions wrote additional superfluous biome palettes
$result[$nextIndex++] = $decoded; $result[$nextIndex++] = $decoded;
}elseif($stream->feof()){
//not enough padding biome arrays for the given version - this is non-critical since we discard the excess anyway, but this should be logged
$logger->error("Wrong number of 3D biome palettes for this chunk version: expected $expectedCount, but got " . ($i + 1) . " - this is not a problem, but may indicate a corrupted chunk");
break;
} }
}catch(BinaryDataException $e){ }catch(BinaryDataException $e){
throw new CorruptedChunkException("Failed to deserialize biome palette $i: " . $e->getMessage(), 0, $e); throw new CorruptedChunkException("Failed to deserialize biome palette $i: " . $e->getMessage(), 0, $e);