diff --git a/src/PocketMine.php b/src/PocketMine.php index 53c794af9e0..e23734adb1d 100644 --- a/src/PocketMine.php +++ b/src/PocketMine.php @@ -70,6 +70,7 @@ use const PHP_EOL; use const PHP_INT_SIZE; use const PHP_VERSION; +use const PTHREADS_INHERIT_NONE; require_once __DIR__ . '/VersionInfo.php'; diff --git a/src/block/BlockFactory.php b/src/block/BlockFactory.php index ec97df002a9..c8d99309017 100644 --- a/src/block/BlockFactory.php +++ b/src/block/BlockFactory.php @@ -503,7 +503,7 @@ public function getBreakTime(Item $item) : float{ $this->remap($magicNumber >= 4 ? Ids::LOG2 : Ids::LOG, ($magicNumber & 0x03) | 0b1100, $wood); $allSidedLogs[] = $wood; - $allSidedLogs[] = new Wood(new BID(Ids::WOOD, $magicNumber | BlockLegacyMetadata::WOOD_FLAG_STRIPPED), "Stripped $name Wood", $logBreakInfo, $treeType, true); + $allSidedLogs[] = new Wood(new BID(Ids::WOOD, $magicNumber | Meta::WOOD_FLAG_STRIPPED), "Stripped $name Wood", $logBreakInfo, $treeType, true); $this->registerAllMeta(new Log(BlockLegacyIdHelper::getStrippedLogIdentifier($treeType), "Stripped " . $name . " Log", $logBreakInfo, $treeType, true)); $this->registerAllMeta(new FenceGate(BlockLegacyIdHelper::getWoodenFenceIdentifier($treeType), $name . " Fence Gate", $planksBreakInfo)); @@ -608,12 +608,12 @@ public function getBreakTime(Item $item) : float{ BreakInfo::instant(), )); $this->registerAllMeta(new FloorCoralFan( - new BlockIdentifierFlattened(Ids::CORAL_FAN, [Ids::CORAL_FAN_DEAD], 0, ItemIds::CORAL_FAN), + new BIDFlattened(Ids::CORAL_FAN, [Ids::CORAL_FAN_DEAD], 0, ItemIds::CORAL_FAN), "Coral Fan", BreakInfo::instant(), )); $this->registerAllMeta(new WallCoralFan( - new BlockIdentifierFlattened(Ids::CORAL_FAN_HANG, [Ids::CORAL_FAN_HANG2, Ids::CORAL_FAN_HANG3], 0, ItemIds::CORAL_FAN), + new BIDFlattened(Ids::CORAL_FAN_HANG, [Ids::CORAL_FAN_HANG2, Ids::CORAL_FAN_HANG3], 0, ItemIds::CORAL_FAN), "Wall Coral Fan", BreakInfo::instant(), )); @@ -956,7 +956,7 @@ private function registerAllMeta(Block $default, Block ...$additional) : void{ private function registerSlabWithDoubleHighBitsRemapping(Slab $block) : void{ $this->register($block); $identifierFlattened = $block->getIdInfo(); - if($identifierFlattened instanceof BlockIdentifierFlattened){ + if($identifierFlattened instanceof BIDFlattened){ $this->remap($identifierFlattened->getSecondId(), $identifierFlattened->getVariant() | 0x8, $block->setSlabType(SlabType::DOUBLE())); } } diff --git a/src/block/BlockLegacyIdHelper.php b/src/block/BlockLegacyIdHelper.php index 50d6b86b4fd..6e493184873 100644 --- a/src/block/BlockLegacyIdHelper.php +++ b/src/block/BlockLegacyIdHelper.php @@ -69,61 +69,61 @@ public static function getWoodenWallSignIdentifier(TreeType $treeType) : BID{ throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenTrapdoorIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenTrapdoorIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::WOODEN_TRAPDOOR, 0); + return new BID(Ids::WOODEN_TRAPDOOR, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::SPRUCE_TRAPDOOR, 0); + return new BID(Ids::SPRUCE_TRAPDOOR, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::BIRCH_TRAPDOOR, 0); + return new BID(Ids::BIRCH_TRAPDOOR, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::JUNGLE_TRAPDOOR, 0); + return new BID(Ids::JUNGLE_TRAPDOOR, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::ACACIA_TRAPDOOR, 0); + return new BID(Ids::ACACIA_TRAPDOOR, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::DARK_OAK_TRAPDOOR, 0); + return new BID(Ids::DARK_OAK_TRAPDOOR, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenButtonIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenButtonIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::WOODEN_BUTTON, 0); + return new BID(Ids::WOODEN_BUTTON, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::SPRUCE_BUTTON, 0); + return new BID(Ids::SPRUCE_BUTTON, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::BIRCH_BUTTON, 0); + return new BID(Ids::BIRCH_BUTTON, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::JUNGLE_BUTTON, 0); + return new BID(Ids::JUNGLE_BUTTON, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::ACACIA_BUTTON, 0); + return new BID(Ids::ACACIA_BUTTON, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::DARK_OAK_BUTTON, 0); + return new BID(Ids::DARK_OAK_BUTTON, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenPressurePlateIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenPressurePlateIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::WOODEN_PRESSURE_PLATE, 0); + return new BID(Ids::WOODEN_PRESSURE_PLATE, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::SPRUCE_PRESSURE_PLATE, 0); + return new BID(Ids::SPRUCE_PRESSURE_PLATE, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::BIRCH_PRESSURE_PLATE, 0); + return new BID(Ids::BIRCH_PRESSURE_PLATE, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::JUNGLE_PRESSURE_PLATE, 0); + return new BID(Ids::JUNGLE_PRESSURE_PLATE, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::ACACIA_PRESSURE_PLATE, 0); + return new BID(Ids::ACACIA_PRESSURE_PLATE, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::DARK_OAK_PRESSURE_PLATE, 0); + return new BID(Ids::DARK_OAK_PRESSURE_PLATE, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenDoorIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenDoorIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): return new BID(Ids::OAK_DOOR_BLOCK, 0, ItemIds::OAK_DOOR); @@ -141,94 +141,94 @@ public static function getWoodenDoorIdentifier(TreeType $treeType) : BlockIdenti throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenFenceIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenFenceIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::OAK_FENCE_GATE, 0); + return new BID(Ids::OAK_FENCE_GATE, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::SPRUCE_FENCE_GATE, 0); + return new BID(Ids::SPRUCE_FENCE_GATE, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::BIRCH_FENCE_GATE, 0); + return new BID(Ids::BIRCH_FENCE_GATE, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::JUNGLE_FENCE_GATE, 0); + return new BID(Ids::JUNGLE_FENCE_GATE, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::ACACIA_FENCE_GATE, 0); + return new BID(Ids::ACACIA_FENCE_GATE, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::DARK_OAK_FENCE_GATE, 0); + return new BID(Ids::DARK_OAK_FENCE_GATE, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getWoodenStairsIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getWoodenStairsIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::OAK_STAIRS, 0); + return new BID(Ids::OAK_STAIRS, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::SPRUCE_STAIRS, 0); + return new BID(Ids::SPRUCE_STAIRS, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::BIRCH_STAIRS, 0); + return new BID(Ids::BIRCH_STAIRS, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::JUNGLE_STAIRS, 0); + return new BID(Ids::JUNGLE_STAIRS, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::ACACIA_STAIRS, 0); + return new BID(Ids::ACACIA_STAIRS, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::DARK_OAK_STAIRS, 0); + return new BID(Ids::DARK_OAK_STAIRS, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getStrippedLogIdentifier(TreeType $treeType) : BlockIdentifier{ + public static function getStrippedLogIdentifier(TreeType $treeType) : BID{ switch($treeType->id()){ case TreeType::OAK()->id(): - return new BlockIdentifier(Ids::STRIPPED_OAK_LOG, 0); + return new BID(Ids::STRIPPED_OAK_LOG, 0); case TreeType::SPRUCE()->id(): - return new BlockIdentifier(Ids::STRIPPED_SPRUCE_LOG, 0); + return new BID(Ids::STRIPPED_SPRUCE_LOG, 0); case TreeType::BIRCH()->id(): - return new BlockIdentifier(Ids::STRIPPED_BIRCH_LOG, 0); + return new BID(Ids::STRIPPED_BIRCH_LOG, 0); case TreeType::JUNGLE()->id(): - return new BlockIdentifier(Ids::STRIPPED_JUNGLE_LOG, 0); + return new BID(Ids::STRIPPED_JUNGLE_LOG, 0); case TreeType::ACACIA()->id(): - return new BlockIdentifier(Ids::STRIPPED_ACACIA_LOG, 0); + return new BID(Ids::STRIPPED_ACACIA_LOG, 0); case TreeType::DARK_OAK()->id(): - return new BlockIdentifier(Ids::STRIPPED_DARK_OAK_LOG, 0); + return new BID(Ids::STRIPPED_DARK_OAK_LOG, 0); } throw new AssumptionFailedError("Switch should cover all wood types"); } - public static function getGlazedTerracottaIdentifier(DyeColor $color) : BlockIdentifier{ + public static function getGlazedTerracottaIdentifier(DyeColor $color) : BID{ switch($color->id()){ case DyeColor::WHITE()->id(): - return new BlockIdentifier(Ids::WHITE_GLAZED_TERRACOTTA, 0); + return new BID(Ids::WHITE_GLAZED_TERRACOTTA, 0); case DyeColor::ORANGE()->id(): - return new BlockIdentifier(Ids::ORANGE_GLAZED_TERRACOTTA, 0); + return new BID(Ids::ORANGE_GLAZED_TERRACOTTA, 0); case DyeColor::MAGENTA()->id(): - return new BlockIdentifier(Ids::MAGENTA_GLAZED_TERRACOTTA, 0); + return new BID(Ids::MAGENTA_GLAZED_TERRACOTTA, 0); case DyeColor::LIGHT_BLUE()->id(): - return new BlockIdentifier(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, 0); + return new BID(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, 0); case DyeColor::YELLOW()->id(): - return new BlockIdentifier(Ids::YELLOW_GLAZED_TERRACOTTA, 0); + return new BID(Ids::YELLOW_GLAZED_TERRACOTTA, 0); case DyeColor::LIME()->id(): - return new BlockIdentifier(Ids::LIME_GLAZED_TERRACOTTA, 0); + return new BID(Ids::LIME_GLAZED_TERRACOTTA, 0); case DyeColor::PINK()->id(): - return new BlockIdentifier(Ids::PINK_GLAZED_TERRACOTTA, 0); + return new BID(Ids::PINK_GLAZED_TERRACOTTA, 0); case DyeColor::GRAY()->id(): - return new BlockIdentifier(Ids::GRAY_GLAZED_TERRACOTTA, 0); + return new BID(Ids::GRAY_GLAZED_TERRACOTTA, 0); case DyeColor::LIGHT_GRAY()->id(): - return new BlockIdentifier(Ids::SILVER_GLAZED_TERRACOTTA, 0); + return new BID(Ids::SILVER_GLAZED_TERRACOTTA, 0); case DyeColor::CYAN()->id(): - return new BlockIdentifier(Ids::CYAN_GLAZED_TERRACOTTA, 0); + return new BID(Ids::CYAN_GLAZED_TERRACOTTA, 0); case DyeColor::PURPLE()->id(): - return new BlockIdentifier(Ids::PURPLE_GLAZED_TERRACOTTA, 0); + return new BID(Ids::PURPLE_GLAZED_TERRACOTTA, 0); case DyeColor::BLUE()->id(): - return new BlockIdentifier(Ids::BLUE_GLAZED_TERRACOTTA, 0); + return new BID(Ids::BLUE_GLAZED_TERRACOTTA, 0); case DyeColor::BROWN()->id(): - return new BlockIdentifier(Ids::BROWN_GLAZED_TERRACOTTA, 0); + return new BID(Ids::BROWN_GLAZED_TERRACOTTA, 0); case DyeColor::GREEN()->id(): - return new BlockIdentifier(Ids::GREEN_GLAZED_TERRACOTTA, 0); + return new BID(Ids::GREEN_GLAZED_TERRACOTTA, 0); case DyeColor::RED()->id(): - return new BlockIdentifier(Ids::RED_GLAZED_TERRACOTTA, 0); + return new BID(Ids::RED_GLAZED_TERRACOTTA, 0); case DyeColor::BLACK()->id(): - return new BlockIdentifier(Ids::BLACK_GLAZED_TERRACOTTA, 0); + return new BID(Ids::BLACK_GLAZED_TERRACOTTA, 0); } throw new AssumptionFailedError("Switch should cover all colours"); } diff --git a/src/item/ItemFactory.php b/src/item/ItemFactory.php index 4a949f843ea..f5495e65ea0 100644 --- a/src/item/ItemFactory.php +++ b/src/item/ItemFactory.php @@ -443,7 +443,7 @@ public function register(Item $item, bool $override = false) : void{ $this->list[self::getListOffset($id, $variant)] = clone $item; } - public function remap(ItemIdentifier $identifier, Item $item, bool $override = false) : void{ + public function remap(IID $identifier, Item $item, bool $override = false) : void{ if(!$override && $this->isRegistered($identifier->getId(), $identifier->getMeta())){ throw new \RuntimeException("Trying to overwrite an already registered item"); } diff --git a/src/network/mcpe/ChunkRequestTask.php b/src/network/mcpe/ChunkRequestTask.php index 7e5eea360ea..8a1de37d795 100644 --- a/src/network/mcpe/ChunkRequestTask.php +++ b/src/network/mcpe/ChunkRequestTask.php @@ -29,6 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelChunkPacket; use pocketmine\network\mcpe\protocol\serializer\PacketBatch; use pocketmine\network\mcpe\protocol\types\ChunkPosition; +use pocketmine\network\mcpe\protocol\types\DimensionIds; use pocketmine\network\mcpe\serializer\ChunkSerializer; use pocketmine\scheduler\AsyncTask; use pocketmine\utils\BinaryStream; diff --git a/src/network/mcpe/compression/Compressor.php b/src/network/mcpe/compression/Compressor.php index 6c042c51d1e..015bdb688d1 100644 --- a/src/network/mcpe/compression/Compressor.php +++ b/src/network/mcpe/compression/Compressor.php @@ -23,6 +23,8 @@ namespace pocketmine\network\mcpe\compression; +use pocketmine\network\mcpe\protocol\types\CompressionAlgorithm; + interface Compressor{ /** * @throws DecompressionException @@ -35,7 +37,7 @@ public function compress(string $payload) : string; * Returns the canonical ID of this compressor, used to tell the remote end how to decompress a packet compressed * with this compressor. * - * @return CompressionAlgorithm::* + * @phpstan-return CompressionAlgorithm::* */ public function getNetworkId() : int; diff --git a/src/network/mcpe/serializer/ChunkSerializer.php b/src/network/mcpe/serializer/ChunkSerializer.php index 6863fd2e937..e52e97a557e 100644 --- a/src/network/mcpe/serializer/ChunkSerializer.php +++ b/src/network/mcpe/serializer/ChunkSerializer.php @@ -159,6 +159,9 @@ public static function serializeTiles(Chunk $chunk) : string{ return $stream->getBuffer(); } + /** + * @phpstan-param DimensionIds::* $dimensionId + */ private static function serializeBiomesAsPalette(Chunk $chunk, int $dimensionId) : string{ [$minSubChunkIndex, $maxSubChunkIndex] = self::getDimensionChunkBounds($dimensionId); $biomeIdMap = LegacyBiomeIdToStringIdMap::getInstance(); diff --git a/src/utils/MainLogger.php b/src/utils/MainLogger.php index 139388af724..b21cd9fd5b1 100644 --- a/src/utils/MainLogger.php +++ b/src/utils/MainLogger.php @@ -79,38 +79,38 @@ public function setFormat(string $format) : void{ } public function emergency($message){ - $this->send($message, \LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED); + $this->send($message, LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED); } public function alert($message){ - $this->send($message, \LogLevel::ALERT, "ALERT", TextFormat::RED); + $this->send($message, LogLevel::ALERT, "ALERT", TextFormat::RED); } public function critical($message){ - $this->send($message, \LogLevel::CRITICAL, "CRITICAL", TextFormat::RED); + $this->send($message, LogLevel::CRITICAL, "CRITICAL", TextFormat::RED); } public function error($message){ - $this->send($message, \LogLevel::ERROR, "ERROR", TextFormat::DARK_RED); + $this->send($message, LogLevel::ERROR, "ERROR", TextFormat::DARK_RED); } public function warning($message){ - $this->send($message, \LogLevel::WARNING, "WARNING", TextFormat::YELLOW); + $this->send($message, LogLevel::WARNING, "WARNING", TextFormat::YELLOW); } public function notice($message){ - $this->send($message, \LogLevel::NOTICE, "NOTICE", TextFormat::AQUA); + $this->send($message, LogLevel::NOTICE, "NOTICE", TextFormat::AQUA); } public function info($message){ - $this->send($message, \LogLevel::INFO, "INFO", TextFormat::WHITE); + $this->send($message, LogLevel::INFO, "INFO", TextFormat::WHITE); } public function debug($message, bool $force = false){ if(!$this->logDebug && !$force){ return; } - $this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY); + $this->send($message, LogLevel::DEBUG, "DEBUG", TextFormat::GRAY); } public function setLogDebug(bool $logDebug) : void{