From 7e343617b9641875c1c6cea58957d94034d0cdde Mon Sep 17 00:00:00 2001 From: ipad54 <63200545+ipad54@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:34:42 +0300 Subject: [PATCH 1/9] Rename ICopper to CopperMaterial (#6470) --- src/block/Copper.php | 4 ++-- src/block/CopperBulb.php | 4 ++-- src/block/CopperDoor.php | 4 ++-- src/block/CopperGrate.php | 4 ++-- src/block/CopperSlab.php | 4 ++-- src/block/CopperStairs.php | 4 ++-- src/block/CopperTrapdoor.php | 4 ++-- src/block/utils/{ICopper.php => CopperMaterial.php} | 6 +++--- .../block/convert/BlockStateDeserializerHelper.php | 10 +++++----- 9 files changed, 22 insertions(+), 22 deletions(-) rename src/block/utils/{ICopper.php => CopperMaterial.php} (85%) diff --git a/src/block/Copper.php b/src/block/Copper.php index 8e678bf42..d285e6ec0 100644 --- a/src/block/Copper.php +++ b/src/block/Copper.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; -class Copper extends Opaque implements ICopper{ +class Copper extends Opaque implements CopperMaterial{ use CopperTrait; } diff --git a/src/block/CopperBulb.php b/src/block/CopperBulb.php index 223c63527..97fc209fe 100644 --- a/src/block/CopperBulb.php +++ b/src/block/CopperBulb.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperOxidation; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; use pocketmine\block\utils\LightableTrait; use pocketmine\block\utils\PoweredByRedstoneTrait; use pocketmine\data\runtime\RuntimeDataDescriber; -class CopperBulb extends Opaque implements ICopper{ +class CopperBulb extends Opaque implements CopperMaterial{ use CopperTrait; use PoweredByRedstoneTrait; use LightableTrait{ diff --git a/src/block/CopperDoor.php b/src/block/CopperDoor.php index d53be2323..82a611206 100644 --- a/src/block/CopperDoor.php +++ b/src/block/CopperDoor.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; use pocketmine\item\Item; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; -class CopperDoor extends Door implements ICopper{ +class CopperDoor extends Door implements CopperMaterial{ use CopperTrait{ onInteract as onInteractCopper; } diff --git a/src/block/CopperGrate.php b/src/block/CopperGrate.php index fb59d846e..d646d1333 100644 --- a/src/block/CopperGrate.php +++ b/src/block/CopperGrate.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; -class CopperGrate extends Transparent implements ICopper{ +class CopperGrate extends Transparent implements CopperMaterial{ use CopperTrait; //TODO: waterlogging! diff --git a/src/block/CopperSlab.php b/src/block/CopperSlab.php index 4194cd854..cc1838e29 100644 --- a/src/block/CopperSlab.php +++ b/src/block/CopperSlab.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; -class CopperSlab extends Slab implements ICopper{ +class CopperSlab extends Slab implements CopperMaterial{ use CopperTrait; } diff --git a/src/block/CopperStairs.php b/src/block/CopperStairs.php index dd8f44f7a..ecb224319 100644 --- a/src/block/CopperStairs.php +++ b/src/block/CopperStairs.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; -class CopperStairs extends Stair implements ICopper{ +class CopperStairs extends Stair implements CopperMaterial{ use CopperTrait; } diff --git a/src/block/CopperTrapdoor.php b/src/block/CopperTrapdoor.php index ab743af44..e7d56fa0c 100644 --- a/src/block/CopperTrapdoor.php +++ b/src/block/CopperTrapdoor.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperTrait; -use pocketmine\block\utils\ICopper; use pocketmine\item\Item; use pocketmine\math\Vector3; use pocketmine\player\Player; -class CopperTrapdoor extends Trapdoor implements ICopper{ +class CopperTrapdoor extends Trapdoor implements CopperMaterial{ use CopperTrait{ onInteract as onInteractCopper; } diff --git a/src/block/utils/ICopper.php b/src/block/utils/CopperMaterial.php similarity index 85% rename from src/block/utils/ICopper.php rename to src/block/utils/CopperMaterial.php index a749efe63..6df22620b 100644 --- a/src/block/utils/ICopper.php +++ b/src/block/utils/CopperMaterial.php @@ -26,13 +26,13 @@ namespace pocketmine\block\utils; /** * Represents copper blocks that have oxidized and waxed variations. */ -interface ICopper{ +interface CopperMaterial{ public function getOxidation() : CopperOxidation; - public function setOxidation(CopperOxidation $oxidation) : ICopper; + public function setOxidation(CopperOxidation $oxidation) : CopperMaterial; public function isWaxed() : bool; - public function setWaxed(bool $waxed) : ICopper; + public function setWaxed(bool $waxed) : CopperMaterial; } diff --git a/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php b/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php index c0807c8a6..e183589c9 100644 --- a/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php +++ b/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php @@ -45,8 +45,8 @@ use pocketmine\block\Slab; use pocketmine\block\Stair; use pocketmine\block\Stem; use pocketmine\block\Trapdoor; +use pocketmine\block\utils\CopperMaterial; use pocketmine\block\utils\CopperOxidation; -use pocketmine\block\utils\ICopper; use pocketmine\block\utils\SlabType; use pocketmine\block\VanillaBlocks; use pocketmine\block\Wall; @@ -98,24 +98,24 @@ final class BlockStateDeserializerHelper{ } /** - * @phpstan-template TBlock of ICopper + * @phpstan-template TBlock of CopperMaterial * * @phpstan-param TBlock $block * @phpstan-return TBlock */ - public static function decodeCopper(ICopper $block, CopperOxidation $oxidation) : ICopper{ + public static function decodeCopper(CopperMaterial $block, CopperOxidation $oxidation) : CopperMaterial{ $block->setOxidation($oxidation); $block->setWaxed(false); return $block; } /** - * @phpstan-template TBlock of ICopper + * @phpstan-template TBlock of CopperMaterial * * @phpstan-param TBlock $block * @phpstan-return TBlock */ - public static function decodeWaxedCopper(ICopper $block, CopperOxidation $oxidation) : ICopper{ + public static function decodeWaxedCopper(CopperMaterial $block, CopperOxidation $oxidation) : CopperMaterial{ $block->setOxidation($oxidation); $block->setWaxed(true); return $block; From 4814db4fe7e5ed9cecf9889d3841788174fd0fd3 Mon Sep 17 00:00:00 2001 From: Dries C Date: Fri, 25 Oct 2024 15:21:51 +0200 Subject: [PATCH 2/9] Assemble 1.21.40 (#6471) --- composer.json | 8 +-- composer.lock | 50 +++++++++---------- src/data/bedrock/BedrockDataFiles.php | 1 + src/data/bedrock/block/BlockStateData.php | 4 +- src/data/bedrock/block/BlockStateNames.php | 1 - src/data/bedrock/block/BlockTypeNames.php | 9 +++- .../convert/BlockObjectToStateSerializer.php | 46 +++++++---------- .../convert/BlockStateDeserializerHelper.php | 5 +- .../BlockStateToObjectDeserializer.php | 35 ++++++++----- .../ItemSerializerDeserializerRegistrar.php | 10 ---- src/data/bedrock/item/ItemTypeNames.php | 16 ++++++ src/network/mcpe/InventoryManager.php | 8 +-- .../mcpe/handler/PreSpawnPacketHandler.php | 4 +- .../handler/ResourcePacksPacketHandler.php | 3 +- tools/generate-bedrock-data-from-packets.php | 2 +- 15 files changed, 107 insertions(+), 95 deletions(-) diff --git a/composer.json b/composer.json index 0b9e8ec6b..9ecbad32f 100644 --- a/composer.json +++ b/composer.json @@ -33,10 +33,10 @@ "composer-runtime-api": "^2.0", "adhocore/json-comment": "~1.2.0", "pocketmine/netresearch-jsonmapper": "~v4.4.999", - "pocketmine/bedrock-block-upgrade-schema": "~4.4.0+bedrock-1.21.30", - "pocketmine/bedrock-data": "~2.13.0+bedrock-1.21.30", - "pocketmine/bedrock-item-upgrade-schema": "~1.12.0+bedrock-1.21.30", - "pocketmine/bedrock-protocol": "~34.0.0+bedrock-1.21.30", + "pocketmine/bedrock-block-upgrade-schema": "~4.5.0+bedrock-1.21.40", + "pocketmine/bedrock-data": "~2.14.0+bedrock-1.21.40", + "pocketmine/bedrock-item-upgrade-schema": "~1.13.0+bedrock-1.21.40", + "pocketmine/bedrock-protocol": "~35.0.0+bedrock-1.21.40", "pocketmine/binaryutils": "^0.2.1", "pocketmine/callback-validator": "^1.0.2", "pocketmine/color": "^0.3.0", diff --git a/composer.lock b/composer.lock index d023c74ac..d4cb38ddc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e16d3ebe48e32bbf96348981249c0ac1", + "content-hash": "5c5882370131d2ae3a043819c05e6f9c", "packages": [ { "name": "adhocore/json-comment", @@ -127,16 +127,16 @@ }, { "name": "pocketmine/bedrock-block-upgrade-schema", - "version": "4.4.0", + "version": "4.5.0", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockBlockUpgradeSchema.git", - "reference": "89e5f6e19c29e0d0d24835639f72a5ef157c2761" + "reference": "7943b894e050d68dd21b5c7fa609827a4e2e30f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/89e5f6e19c29e0d0d24835639f72a5ef157c2761", - "reference": "89e5f6e19c29e0d0d24835639f72a5ef157c2761", + "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/7943b894e050d68dd21b5c7fa609827a4e2e30f1", + "reference": "7943b894e050d68dd21b5c7fa609827a4e2e30f1", "shasum": "" }, "type": "library", @@ -147,22 +147,22 @@ "description": "Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves", "support": { "issues": "https://github.com/pmmp/BedrockBlockUpgradeSchema/issues", - "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/4.4.0" + "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/4.5.0" }, - "time": "2024-09-17T16:06:36+00:00" + "time": "2024-10-23T16:15:24+00:00" }, { "name": "pocketmine/bedrock-data", - "version": "2.13.0+bedrock-1.21.30", + "version": "2.14.0+bedrock-1.21.40", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "23d9356b866654cbd2a62b31373118bedb4a2562" + "reference": "606d32ae426164b0615898b95d10e23293bed6ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/23d9356b866654cbd2a62b31373118bedb4a2562", - "reference": "23d9356b866654cbd2a62b31373118bedb4a2562", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/606d32ae426164b0615898b95d10e23293bed6ac", + "reference": "606d32ae426164b0615898b95d10e23293bed6ac", "shasum": "" }, "type": "library", @@ -173,22 +173,22 @@ "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/BedrockData/issues", - "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.21.30" + "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.21.40" }, - "time": "2024-09-17T16:03:14+00:00" + "time": "2024-10-23T19:19:16+00:00" }, { "name": "pocketmine/bedrock-item-upgrade-schema", - "version": "1.12.0", + "version": "1.13.0", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockItemUpgradeSchema.git", - "reference": "85a0014c7dfd4a25c22a9efb0b447afb7dc6c409" + "reference": "1dee9bbd0aaa65ed108b377b402746defe10b3b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/85a0014c7dfd4a25c22a9efb0b447afb7dc6c409", - "reference": "85a0014c7dfd4a25c22a9efb0b447afb7dc6c409", + "url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/1dee9bbd0aaa65ed108b377b402746defe10b3b0", + "reference": "1dee9bbd0aaa65ed108b377b402746defe10b3b0", "shasum": "" }, "type": "library", @@ -199,22 +199,22 @@ "description": "JSON schemas for upgrading items found in older Minecraft: Bedrock world saves", "support": { "issues": "https://github.com/pmmp/BedrockItemUpgradeSchema/issues", - "source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/1.12.0" + "source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/1.13.0" }, - "time": "2024-09-11T19:48:31+00:00" + "time": "2024-10-23T18:38:43+00:00" }, { "name": "pocketmine/bedrock-protocol", - "version": "34.0.0+bedrock-1.21.30", + "version": "35.0.0+bedrock-1.21.40", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "440c8078c66cc2a8f2abf58468df7df7246ee33b" + "reference": "6aa7cbeb4a7ec6fa58f9024aeaddad7c5c65a459" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/440c8078c66cc2a8f2abf58468df7df7246ee33b", - "reference": "440c8078c66cc2a8f2abf58468df7df7246ee33b", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/6aa7cbeb4a7ec6fa58f9024aeaddad7c5c65a459", + "reference": "6aa7cbeb4a7ec6fa58f9024aeaddad7c5c65a459", "shasum": "" }, "require": { @@ -245,9 +245,9 @@ "description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP", "support": { "issues": "https://github.com/pmmp/BedrockProtocol/issues", - "source": "https://github.com/pmmp/BedrockProtocol/tree/34.0.0+bedrock-1.21.30" + "source": "https://github.com/pmmp/BedrockProtocol/tree/35.0.0+bedrock-1.21.40" }, - "time": "2024-09-18T20:58:42+00:00" + "time": "2024-10-24T15:45:43+00:00" }, { "name": "pocketmine/binaryutils", diff --git a/src/data/bedrock/BedrockDataFiles.php b/src/data/bedrock/BedrockDataFiles.php index 2c9350ca3..5c476ca1c 100644 --- a/src/data/bedrock/BedrockDataFiles.php +++ b/src/data/bedrock/BedrockDataFiles.php @@ -35,6 +35,7 @@ final class BedrockDataFiles{ public const BIOME_DEFINITIONS_FULL_NBT = BEDROCK_DATA_PATH . '/biome_definitions_full.nbt'; public const BIOME_ID_MAP_JSON = BEDROCK_DATA_PATH . '/biome_id_map.json'; public const BLOCK_ID_TO_ITEM_ID_MAP_JSON = BEDROCK_DATA_PATH . '/block_id_to_item_id_map.json'; + public const BLOCK_PROPERTIES_TABLE_JSON = BEDROCK_DATA_PATH . '/block_properties_table.json'; public const BLOCK_STATE_META_MAP_JSON = BEDROCK_DATA_PATH . '/block_state_meta_map.json'; public const CANONICAL_BLOCK_STATES_NBT = BEDROCK_DATA_PATH . '/canonical_block_states.nbt'; public const COMMAND_ARG_TYPES_JSON = BEDROCK_DATA_PATH . '/command_arg_types.json'; diff --git a/src/data/bedrock/block/BlockStateData.php b/src/data/bedrock/block/BlockStateData.php index f405e4cf6..6624c4ae0 100644 --- a/src/data/bedrock/block/BlockStateData.php +++ b/src/data/bedrock/block/BlockStateData.php @@ -45,8 +45,8 @@ final class BlockStateData{ public const CURRENT_VERSION = (1 << 24) | //major (21 << 16) | //minor - (30 << 8) | //patch - (7); //revision + (40 << 8) | //patch + (1); //revision public const TAG_NAME = "name"; public const TAG_STATES = "states"; diff --git a/src/data/bedrock/block/BlockStateNames.php b/src/data/bedrock/block/BlockStateNames.php index c54822671..0f4b87426 100644 --- a/src/data/bedrock/block/BlockStateNames.php +++ b/src/data/bedrock/block/BlockStateNames.php @@ -114,7 +114,6 @@ final class BlockStateNames{ public const SEA_GRASS_TYPE = "sea_grass_type"; public const STABILITY = "stability"; public const STABILITY_CHECK = "stability_check"; - public const STRIPPED_BIT = "stripped_bit"; public const STRUCTURE_BLOCK_TYPE = "structure_block_type"; public const SUSPENDED_BIT = "suspended_bit"; public const TOGGLE_BIT = "toggle_bit"; diff --git a/src/data/bedrock/block/BlockTypeNames.php b/src/data/bedrock/block/BlockTypeNames.php index ec5565715..029a5f6aa 100644 --- a/src/data/bedrock/block/BlockTypeNames.php +++ b/src/data/bedrock/block/BlockTypeNames.php @@ -262,6 +262,7 @@ final class BlockTypeNames{ public const CRACKED_STONE_BRICKS = "minecraft:cracked_stone_bricks"; public const CRAFTER = "minecraft:crafter"; public const CRAFTING_TABLE = "minecraft:crafting_table"; + public const CREEPER_HEAD = "minecraft:creeper_head"; public const CRIMSON_BUTTON = "minecraft:crimson_button"; public const CRIMSON_DOOR = "minecraft:crimson_door"; public const CRIMSON_DOUBLE_SLAB = "minecraft:crimson_double_slab"; @@ -384,6 +385,7 @@ final class BlockTypeNames{ public const DISPENSER = "minecraft:dispenser"; public const DOUBLE_CUT_COPPER_SLAB = "minecraft:double_cut_copper_slab"; public const DRAGON_EGG = "minecraft:dragon_egg"; + public const DRAGON_HEAD = "minecraft:dragon_head"; public const DRIED_KELP_BLOCK = "minecraft:dried_kelp_block"; public const DRIPSTONE_BLOCK = "minecraft:dripstone_block"; public const DROPPER = "minecraft:dropper"; @@ -797,6 +799,7 @@ final class BlockTypeNames{ public const MUD_BRICK_WALL = "minecraft:mud_brick_wall"; public const MUD_BRICKS = "minecraft:mud_bricks"; public const MUDDY_MANGROVE_ROOTS = "minecraft:muddy_mangrove_roots"; + public const MUSHROOM_STEM = "minecraft:mushroom_stem"; public const MYCELIUM = "minecraft:mycelium"; public const NETHER_BRICK = "minecraft:nether_brick"; public const NETHER_BRICK_DOUBLE_SLAB = "minecraft:nether_brick_double_slab"; @@ -857,6 +860,7 @@ final class BlockTypeNames{ public const PEONY = "minecraft:peony"; public const PETRIFIED_OAK_DOUBLE_SLAB = "minecraft:petrified_oak_double_slab"; public const PETRIFIED_OAK_SLAB = "minecraft:petrified_oak_slab"; + public const PIGLIN_HEAD = "minecraft:piglin_head"; public const PINK_CANDLE = "minecraft:pink_candle"; public const PINK_CANDLE_CAKE = "minecraft:pink_candle_cake"; public const PINK_CARPET = "minecraft:pink_carpet"; @@ -874,6 +878,7 @@ final class BlockTypeNames{ public const PISTON_ARM_COLLISION = "minecraft:piston_arm_collision"; public const PITCHER_CROP = "minecraft:pitcher_crop"; public const PITCHER_PLANT = "minecraft:pitcher_plant"; + public const PLAYER_HEAD = "minecraft:player_head"; public const PODZOL = "minecraft:podzol"; public const POINTED_DRIPSTONE = "minecraft:pointed_dripstone"; public const POLISHED_ANDESITE = "minecraft:polished_andesite"; @@ -1009,7 +1014,7 @@ final class BlockTypeNames{ public const SHORT_GRASS = "minecraft:short_grass"; public const SHROOMLIGHT = "minecraft:shroomlight"; public const SILVER_GLAZED_TERRACOTTA = "minecraft:silver_glazed_terracotta"; - public const SKULL = "minecraft:skull"; + public const SKELETON_SKULL = "minecraft:skeleton_skull"; public const SLIME = "minecraft:slime"; public const SMALL_AMETHYST_BUD = "minecraft:small_amethyst_bud"; public const SMALL_DRIPLEAF_BLOCK = "minecraft:small_dripleaf_block"; @@ -1229,6 +1234,7 @@ final class BlockTypeNames{ public const WHITE_TULIP = "minecraft:white_tulip"; public const WHITE_WOOL = "minecraft:white_wool"; public const WITHER_ROSE = "minecraft:wither_rose"; + public const WITHER_SKELETON_SKULL = "minecraft:wither_skeleton_skull"; public const WOODEN_BUTTON = "minecraft:wooden_button"; public const WOODEN_DOOR = "minecraft:wooden_door"; public const WOODEN_PRESSURE_PLATE = "minecraft:wooden_pressure_plate"; @@ -1243,4 +1249,5 @@ final class BlockTypeNames{ public const YELLOW_STAINED_GLASS_PANE = "minecraft:yellow_stained_glass_pane"; public const YELLOW_TERRACOTTA = "minecraft:yellow_terracotta"; public const YELLOW_WOOL = "minecraft:yellow_wool"; + public const ZOMBIE_HEAD = "minecraft:zombie_head"; } diff --git a/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php b/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php index af6547729..a7fee6efb 100644 --- a/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php +++ b/src/data/bedrock/block/convert/BlockObjectToStateSerializer.php @@ -151,6 +151,7 @@ use pocketmine\block\utils\DripleafState; use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\FroglightType; use pocketmine\block\utils\LeverFacing; +use pocketmine\block\utils\MobHeadType; use pocketmine\block\VanillaBlocks as Blocks; use pocketmine\block\Vine; use pocketmine\block\Wall; @@ -205,6 +206,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ $this->registerFlatWoodBlockSerializers(); $this->registerLeavesSerializers(); $this->registerSaplingSerializers(); + $this->registerMobHeadSerializers(); $this->registerSimpleSerializers(); $this->registerSerializers(); } @@ -624,17 +626,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::CHERRY_PLANKS(), Ids::CHERRY_PLANKS); $this->mapSlab(Blocks::CHERRY_SLAB(), Ids::CHERRY_SLAB, Ids::CHERRY_DOUBLE_SLAB); $this->mapStairs(Blocks::CHERRY_STAIRS(), Ids::CHERRY_STAIRS); - $this->map(Blocks::CHERRY_WOOD(), function(Wood $block) : Writer{ - //we can't use the standard method for this because cherry_wood has a useless property attached to it - if(!$block->isStripped()){ - return Writer::create(Ids::CHERRY_WOOD) - ->writePillarAxis($block->getAxis()) - ->writeBool(StateNames::STRIPPED_BIT, false); //this is useless, but it has to be written - }else{ - return Writer::create(Ids::STRIPPED_CHERRY_WOOD) - ->writePillarAxis($block->getAxis()); - } - }); + $this->mapLog(Blocks::CHERRY_WOOD(), Ids::CHERRY_WOOD, Ids::STRIPPED_CHERRY_WOOD); $this->map(Blocks::CRIMSON_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::CRIMSON_BUTTON))); $this->map(Blocks::CRIMSON_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::CRIMSON_DOOR))); @@ -690,17 +682,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::MANGROVE_PLANKS(), Ids::MANGROVE_PLANKS); $this->mapSlab(Blocks::MANGROVE_SLAB(), Ids::MANGROVE_SLAB, Ids::MANGROVE_DOUBLE_SLAB); $this->mapStairs(Blocks::MANGROVE_STAIRS(), Ids::MANGROVE_STAIRS); - $this->map(Blocks::MANGROVE_WOOD(), function(Wood $block) : Writer{ - //we can't use the standard method for this because mangrove_wood has a useless property attached to it - if(!$block->isStripped()){ - return Writer::create(Ids::MANGROVE_WOOD) - ->writePillarAxis($block->getAxis()) - ->writeBool(StateNames::STRIPPED_BIT, false); //this is useless, but it has to be written - }else{ - return Writer::create(Ids::STRIPPED_MANGROVE_WOOD) - ->writePillarAxis($block->getAxis()); - } - }); + $this->mapLog(Blocks::MANGROVE_WOOD(), Ids::MANGROVE_WOOD, Ids::STRIPPED_MANGROVE_WOOD); $this->map(Blocks::OAK_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::WOODEN_BUTTON))); $this->map(Blocks::OAK_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::WOODEN_DOOR))); @@ -775,6 +757,18 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ } } + private function registerMobHeadSerializers() : void{ + $this->map(Blocks::MOB_HEAD(), fn(MobHead $block) => Writer::create(match ($block->getMobHeadType()){ + MobHeadType::CREEPER => Ids::CREEPER_HEAD, + MobHeadType::DRAGON => Ids::DRAGON_HEAD, + MobHeadType::PIGLIN => Ids::PIGLIN_HEAD, + MobHeadType::PLAYER => Ids::PLAYER_HEAD, + MobHeadType::SKELETON => Ids::SKELETON_SKULL, + MobHeadType::WITHER_SKELETON => Ids::WITHER_SKELETON_SKULL, + MobHeadType::ZOMBIE => Ids::ZOMBIE_HEAD, + })->writeFacingWithoutDown($block->getFacing())); + } + private function registerSimpleSerializers() : void{ $this->mapSimple(Blocks::AIR(), Ids::AIR); $this->mapSimple(Blocks::AMETHYST(), Ids::AMETHYST_BLOCK); @@ -1078,7 +1072,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ ->writeBool(StateNames::RAIL_DATA_BIT, $block->isPowered()) ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); }); - $this->map(Blocks::ALL_SIDED_MUSHROOM_STEM(), fn() => Writer::create(Ids::BROWN_MUSHROOM_BLOCK) + $this->map(Blocks::ALL_SIDED_MUSHROOM_STEM(), fn() => Writer::create(Ids::MUSHROOM_STEM) ->writeInt(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM)); $this->map(Blocks::AMETHYST_CLUSTER(), fn(AmethystCluster $block) => Writer::create( match($stage = $block->getStage()){ @@ -1483,10 +1477,6 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ }); $this->map(Blocks::MATERIAL_REDUCER(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, Writer::create(Ids::MATERIAL_REDUCER))); $this->map(Blocks::MELON_STEM(), fn(MelonStem $block) => Helper::encodeStem($block, new Writer(Ids::MELON_STEM))); - $this->map(Blocks::MOB_HEAD(), function(MobHead $block) : Writer{ - return Writer::create(Ids::SKULL) - ->writeFacingWithoutDown($block->getFacing()); - }); $this->mapSlab(Blocks::MOSSY_COBBLESTONE_SLAB(), Ids::MOSSY_COBBLESTONE_SLAB, Ids::MOSSY_COBBLESTONE_DOUBLE_SLAB); $this->mapStairs(Blocks::MOSSY_COBBLESTONE_STAIRS(), Ids::MOSSY_COBBLESTONE_STAIRS); $this->map(Blocks::MOSSY_COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, Writer::create(Ids::MOSSY_COBBLESTONE_WALL))); @@ -1498,7 +1488,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{ $this->map(Blocks::MUD_BRICK_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::MUD_BRICK_WALL))); $this->map(Blocks::MUDDY_MANGROVE_ROOTS(), fn(SimplePillar $block) => Writer::create(Ids::MUDDY_MANGROVE_ROOTS) ->writePillarAxis($block->getAxis())); - $this->map(Blocks::MUSHROOM_STEM(), fn() => Writer::create(Ids::BROWN_MUSHROOM_BLOCK) + $this->map(Blocks::MUSHROOM_STEM(), fn() => Writer::create(Ids::MUSHROOM_STEM) ->writeInt(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_STEM)); $this->mapSlab(Blocks::NETHER_BRICK_SLAB(), Ids::NETHER_BRICK_SLAB, Ids::NETHER_BRICK_DOUBLE_SLAB); $this->mapStairs(Blocks::NETHER_BRICK_STAIRS(), Ids::NETHER_BRICK_STAIRS); diff --git a/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php b/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php index 47c0fd4af..c51cda768 100644 --- a/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php +++ b/src/data/bedrock/block/convert/BlockStateDeserializerHelper.php @@ -50,7 +50,6 @@ use pocketmine\block\Stem; use pocketmine\block\Trapdoor; use pocketmine\block\utils\CopperOxidation; use pocketmine\block\utils\SlabType; -use pocketmine\block\VanillaBlocks; use pocketmine\block\Wall; use pocketmine\block\WallSign; use pocketmine\block\WeightedPressurePlate; @@ -210,8 +209,8 @@ final class BlockStateDeserializerHelper{ /** @throws BlockStateDeserializeException */ public static function decodeMushroomBlock(RedMushroomBlock $block, BlockStateReader $in) : Block{ switch($type = $in->readBoundedInt(BlockStateNames::HUGE_MUSHROOM_BITS, 0, 15)){ - case BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM: return VanillaBlocks::ALL_SIDED_MUSHROOM_STEM(); - case BlockLegacyMetadata::MUSHROOM_BLOCK_STEM: return VanillaBlocks::MUSHROOM_STEM(); + case BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM: + case BlockLegacyMetadata::MUSHROOM_BLOCK_STEM: throw new BlockStateDeserializeException("This state does not exist"); default: //invalid types get left as default $type = MushroomBlockTypeIdMap::getInstance()->fromId($type); diff --git a/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php b/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php index eb0cb8d50..405f6e53e 100644 --- a/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php +++ b/src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php @@ -45,6 +45,7 @@ use pocketmine\block\utils\DripleafState; use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\FroglightType; use pocketmine\block\utils\LeverFacing; +use pocketmine\block\utils\MobHeadType; use pocketmine\block\VanillaBlocks as Blocks; use pocketmine\block\Wood; use pocketmine\data\bedrock\block\BlockLegacyMetadata; @@ -85,6 +86,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ $this->registerLeavesDeserializers(); $this->registerSaplingDeserializers(); $this->registerLightDeserializers(); + $this->registerMobHeadDeserializers(); $this->registerSimpleDeserializers(); $this->registerDeserializers(); } @@ -531,10 +533,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ $this->mapSimple(Ids::CHERRY_PLANKS, fn() => Blocks::CHERRY_PLANKS()); $this->mapSlab(Ids::CHERRY_SLAB, Ids::CHERRY_DOUBLE_SLAB, fn() => Blocks::CHERRY_SLAB()); $this->mapStairs(Ids::CHERRY_STAIRS, fn() => Blocks::CHERRY_STAIRS()); - $this->map(Ids::CHERRY_WOOD, function(Reader $in){ - $in->ignored(StateNames::STRIPPED_BIT); //this is also ignored by vanilla - return Helper::decodeLog(Blocks::CHERRY_WOOD(), false, $in); - }); + $this->map(Ids::CHERRY_WOOD, fn(Reader $in) => Helper::decodeLog(Blocks::CHERRY_WOOD(), false, $in)); $this->map(Ids::STRIPPED_CHERRY_WOOD, fn(Reader $in) => Helper::decodeLog(Blocks::CHERRY_WOOD(), true, $in)); $this->map(Ids::CRIMSON_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::CRIMSON_BUTTON(), $in)); @@ -591,10 +590,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ $this->mapSimple(Ids::MANGROVE_PLANKS, fn() => Blocks::MANGROVE_PLANKS()); $this->mapSlab(Ids::MANGROVE_SLAB, Ids::MANGROVE_DOUBLE_SLAB, fn() => Blocks::MANGROVE_SLAB()); $this->mapStairs(Ids::MANGROVE_STAIRS, fn() => Blocks::MANGROVE_STAIRS()); - $this->map(Ids::MANGROVE_WOOD, function(Reader $in){ - $in->ignored(StateNames::STRIPPED_BIT); //this is also ignored by vanilla - return Helper::decodeLog(Blocks::MANGROVE_WOOD(), false, $in); - }); + $this->map(Ids::MANGROVE_WOOD, fn(Reader $in) => Helper::decodeLog(Blocks::MANGROVE_WOOD(), false, $in)); $this->map(Ids::STRIPPED_MANGROVE_WOOD, fn(Reader $in) => Helper::decodeLog(Blocks::MANGROVE_WOOD(), true, $in)); //oak - due to age, many of these don't specify "oak", making for confusing reading @@ -690,6 +686,20 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ } } + private function registerMobHeadDeserializers() : void{ + foreach([ + Ids::CREEPER_HEAD => MobHeadType::CREEPER, + Ids::DRAGON_HEAD => MobHeadType::DRAGON, + Ids::PIGLIN_HEAD => MobHeadType::PIGLIN, + Ids::PLAYER_HEAD => MobHeadType::PLAYER, + Ids::SKELETON_SKULL => MobHeadType::SKELETON, + Ids::WITHER_SKELETON_SKULL => MobHeadType::WITHER_SKELETON, + Ids::ZOMBIE_HEAD => MobHeadType::ZOMBIE + ] as $id => $mobHeadType){ + $this->map($id, fn(Reader $in) => Blocks::MOB_HEAD()->setMobHeadType($mobHeadType)->setFacing($in->readFacingWithoutDown())); + } + } + private function registerSimpleDeserializers() : void{ $this->mapSimple(Ids::AIR, fn() => Blocks::AIR()); $this->mapSimple(Ids::AMETHYST_BLOCK, fn() => Blocks::AMETHYST()); @@ -1099,6 +1109,11 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ $this->mapSlab(Ids::BRICK_SLAB, Ids::BRICK_DOUBLE_SLAB, fn() => Blocks::BRICK_SLAB()); $this->mapStairs(Ids::BRICK_STAIRS, fn() => Blocks::BRICK_STAIRS()); $this->map(Ids::BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::BRICK_WALL(), $in)); + $this->map(Ids::MUSHROOM_STEM, fn(Reader $in) => match($in->readBoundedInt(StateNames::HUGE_MUSHROOM_BITS, 0, 15)){ + BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM => Blocks::ALL_SIDED_MUSHROOM_STEM(), + BlockLegacyMetadata::MUSHROOM_BLOCK_STEM => Blocks::MUSHROOM_STEM(), + default => throw new BlockStateDeserializeException("This state does not exist"), + }); $this->map(Ids::BROWN_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::BROWN_MUSHROOM_BLOCK(), $in)); $this->map(Ids::CACTUS, function(Reader $in) : Block{ return Blocks::CACTUS() @@ -1521,10 +1536,6 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{ ->setCount($in->readBoundedInt(StateNames::CLUSTER_COUNT, 0, 3) + 1) ->setUnderwater(!$in->readBool(StateNames::DEAD_BIT)); }); - $this->map(Ids::SKULL, function(Reader $in) : Block{ - return Blocks::MOB_HEAD() - ->setFacing($in->readFacingWithoutDown()); - }); $this->map(Ids::SMOKER, function(Reader $in) : Block{ return Blocks::SMOKER() ->setFacing($in->readCardinalHorizontalFacing()) diff --git a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php index 7a720559e..0af17bc73 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -25,7 +25,6 @@ namespace pocketmine\data\bedrock\item; use pocketmine\block\Bed; use pocketmine\block\Block; -use pocketmine\block\MobHead; use pocketmine\block\utils\DyeColor; use pocketmine\block\VanillaBlocks as Blocks; use pocketmine\data\bedrock\CompoundTypeIds; @@ -33,7 +32,6 @@ use pocketmine\data\bedrock\DyeColorIdMap; use pocketmine\data\bedrock\item\ItemTypeNames as Ids; use pocketmine\data\bedrock\item\SavedItemData as Data; use pocketmine\data\bedrock\MedicineTypeIdMap; -use pocketmine\data\bedrock\MobHeadTypeIdMap; use pocketmine\data\bedrock\PotionTypeIdMap; use pocketmine\data\bedrock\SuspiciousStewTypeIdMap; use pocketmine\item\Banner; @@ -464,14 +462,6 @@ final class ItemSerializerDeserializerRegistrar{ }, fn(Bed $block) => DyeColorIdMap::getInstance()->toId($block->getColor()) ); - $this->map1to1BlockWithMeta( - Ids::SKULL, - Blocks::MOB_HEAD(), - function(MobHead $block, int $meta) : void{ - $block->setMobHeadType(MobHeadTypeIdMap::getInstance()->fromId($meta) ?? throw new ItemTypeDeserializeException("Unknown mob head type ID $meta")); - }, - fn(MobHead $block) => MobHeadTypeIdMap::getInstance()->toId($block->getMobHeadType()) - ); } /** diff --git a/src/data/bedrock/item/ItemTypeNames.php b/src/data/bedrock/item/ItemTypeNames.php index 06ae28cec..03b32d482 100644 --- a/src/data/bedrock/item/ItemTypeNames.php +++ b/src/data/bedrock/item/ItemTypeNames.php @@ -66,12 +66,14 @@ final class ItemTypeNames{ public const BIRCH_DOOR = "minecraft:birch_door"; public const BIRCH_HANGING_SIGN = "minecraft:birch_hanging_sign"; public const BIRCH_SIGN = "minecraft:birch_sign"; + public const BLACK_BUNDLE = "minecraft:black_bundle"; public const BLACK_DYE = "minecraft:black_dye"; public const BLADE_POTTERY_SHERD = "minecraft:blade_pottery_sherd"; public const BLAZE_POWDER = "minecraft:blaze_powder"; public const BLAZE_ROD = "minecraft:blaze_rod"; public const BLAZE_SPAWN_EGG = "minecraft:blaze_spawn_egg"; public const BLEACH = "minecraft:bleach"; + public const BLUE_BUNDLE = "minecraft:blue_bundle"; public const BLUE_DYE = "minecraft:blue_dye"; public const BOAT = "minecraft:boat"; public const BOGGED_SPAWN_EGG = "minecraft:bogged_spawn_egg"; @@ -88,6 +90,7 @@ final class ItemTypeNames{ public const BREWER_POTTERY_SHERD = "minecraft:brewer_pottery_sherd"; public const BREWING_STAND = "minecraft:brewing_stand"; public const BRICK = "minecraft:brick"; + public const BROWN_BUNDLE = "minecraft:brown_bundle"; public const BROWN_DYE = "minecraft:brown_dye"; public const BRUSH = "minecraft:brush"; public const BUCKET = "minecraft:bucket"; @@ -157,6 +160,7 @@ final class ItemTypeNames{ public const CRIMSON_HANGING_SIGN = "minecraft:crimson_hanging_sign"; public const CRIMSON_SIGN = "minecraft:crimson_sign"; public const CROSSBOW = "minecraft:crossbow"; + public const CYAN_BUNDLE = "minecraft:cyan_bundle"; public const CYAN_DYE = "minecraft:cyan_dye"; public const DANGER_POTTERY_SHERD = "minecraft:danger_pottery_sherd"; public const DARK_OAK_BOAT = "minecraft:dark_oak_boat"; @@ -255,7 +259,9 @@ final class ItemTypeNames{ public const GOLDEN_PICKAXE = "minecraft:golden_pickaxe"; public const GOLDEN_SHOVEL = "minecraft:golden_shovel"; public const GOLDEN_SWORD = "minecraft:golden_sword"; + public const GRAY_BUNDLE = "minecraft:gray_bundle"; public const GRAY_DYE = "minecraft:gray_dye"; + public const GREEN_BUNDLE = "minecraft:green_bundle"; public const GREEN_DYE = "minecraft:green_dye"; public const GUARDIAN_SPAWN_EGG = "minecraft:guardian_spawn_egg"; public const GUNPOWDER = "minecraft:gunpowder"; @@ -309,8 +315,11 @@ final class ItemTypeNames{ public const LEAVES = "minecraft:leaves"; public const LEAVES2 = "minecraft:leaves2"; public const LIGHT_BLOCK = "minecraft:light_block"; + public const LIGHT_BLUE_BUNDLE = "minecraft:light_blue_bundle"; public const LIGHT_BLUE_DYE = "minecraft:light_blue_dye"; + public const LIGHT_GRAY_BUNDLE = "minecraft:light_gray_bundle"; public const LIGHT_GRAY_DYE = "minecraft:light_gray_dye"; + public const LIME_BUNDLE = "minecraft:lime_bundle"; public const LIME_DYE = "minecraft:lime_dye"; public const LINGERING_POTION = "minecraft:lingering_potion"; public const LLAMA_SPAWN_EGG = "minecraft:llama_spawn_egg"; @@ -318,6 +327,7 @@ final class ItemTypeNames{ public const LOG = "minecraft:log"; public const LOG2 = "minecraft:log2"; public const MACE = "minecraft:mace"; + public const MAGENTA_BUNDLE = "minecraft:magenta_bundle"; public const MAGENTA_DYE = "minecraft:magenta_dye"; public const MAGMA_CREAM = "minecraft:magma_cream"; public const MAGMA_CUBE_SPAWN_EGG = "minecraft:magma_cube_spawn_egg"; @@ -384,6 +394,7 @@ final class ItemTypeNames{ public const OCELOT_SPAWN_EGG = "minecraft:ocelot_spawn_egg"; public const OMINOUS_BOTTLE = "minecraft:ominous_bottle"; public const OMINOUS_TRIAL_KEY = "minecraft:ominous_trial_key"; + public const ORANGE_BUNDLE = "minecraft:orange_bundle"; public const ORANGE_DYE = "minecraft:orange_dye"; public const OXIDIZED_COPPER_DOOR = "minecraft:oxidized_copper_door"; public const PAINTING = "minecraft:painting"; @@ -397,6 +408,7 @@ final class ItemTypeNames{ public const PIGLIN_BRUTE_SPAWN_EGG = "minecraft:piglin_brute_spawn_egg"; public const PIGLIN_SPAWN_EGG = "minecraft:piglin_spawn_egg"; public const PILLAGER_SPAWN_EGG = "minecraft:pillager_spawn_egg"; + public const PINK_BUNDLE = "minecraft:pink_bundle"; public const PINK_DYE = "minecraft:pink_dye"; public const PITCHER_POD = "minecraft:pitcher_pod"; public const PLANKS = "minecraft:planks"; @@ -416,6 +428,7 @@ final class ItemTypeNames{ public const PUFFERFISH_SPAWN_EGG = "minecraft:pufferfish_spawn_egg"; public const PUMPKIN_PIE = "minecraft:pumpkin_pie"; public const PUMPKIN_SEEDS = "minecraft:pumpkin_seeds"; + public const PURPLE_BUNDLE = "minecraft:purple_bundle"; public const PURPLE_DYE = "minecraft:purple_dye"; public const QUARTZ = "minecraft:quartz"; public const RABBIT = "minecraft:rabbit"; @@ -430,6 +443,7 @@ final class ItemTypeNames{ public const RAW_GOLD = "minecraft:raw_gold"; public const RAW_IRON = "minecraft:raw_iron"; public const RECOVERY_COMPASS = "minecraft:recovery_compass"; + public const RED_BUNDLE = "minecraft:red_bundle"; public const RED_DYE = "minecraft:red_dye"; public const RED_FLOWER = "minecraft:red_flower"; public const REDSTONE = "minecraft:redstone"; @@ -537,6 +551,7 @@ final class ItemTypeNames{ public const WEATHERED_COPPER_DOOR = "minecraft:weathered_copper_door"; public const WHEAT = "minecraft:wheat"; public const WHEAT_SEEDS = "minecraft:wheat_seeds"; + public const WHITE_BUNDLE = "minecraft:white_bundle"; public const WHITE_DYE = "minecraft:white_dye"; public const WILD_ARMOR_TRIM_SMITHING_TEMPLATE = "minecraft:wild_armor_trim_smithing_template"; public const WIND_CHARGE = "minecraft:wind_charge"; @@ -556,6 +571,7 @@ final class ItemTypeNames{ public const WOOL = "minecraft:wool"; public const WRITABLE_BOOK = "minecraft:writable_book"; public const WRITTEN_BOOK = "minecraft:written_book"; + public const YELLOW_BUNDLE = "minecraft:yellow_bundle"; public const YELLOW_DYE = "minecraft:yellow_dye"; public const ZOGLIN_SPAWN_EGG = "minecraft:zoglin_spawn_egg"; public const ZOMBIE_HORSE_SPAWN_EGG = "minecraft:zombie_horse_spawn_egg"; diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index 99af73707..c0969b61b 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -502,7 +502,7 @@ class InventoryManager{ $windowId, $netSlot, new FullContainerName($this->lastInventoryNetworkId), - 0, + new ItemStackWrapper(0, ItemStack::null()), new ItemStackWrapper(0, ItemStack::null()) )); } @@ -511,7 +511,7 @@ class InventoryManager{ $windowId, $netSlot, new FullContainerName($this->lastInventoryNetworkId), - 0, + new ItemStackWrapper(0, ItemStack::null()), $itemStackWrapper )); } @@ -532,10 +532,10 @@ class InventoryManager{ $windowId, array_fill_keys(array_keys($itemStackWrappers), new ItemStackWrapper(0, ItemStack::null())), new FullContainerName($this->lastInventoryNetworkId), - 0 + new ItemStackWrapper(0, ItemStack::null()) )); //now send the real contents - $this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers, new FullContainerName($this->lastInventoryNetworkId), 0)); + $this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers, new FullContainerName($this->lastInventoryNetworkId), new ItemStackWrapper(0, ItemStack::null()))); } public function syncSlot(Inventory $inventory, int $slot, ItemStack $itemStack) : void{ diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index f80bacfc1..b80874938 100644 --- a/src/network/mcpe/handler/PreSpawnPacketHandler.php +++ b/src/network/mcpe/handler/PreSpawnPacketHandler.php @@ -39,7 +39,7 @@ use pocketmine\network\mcpe\protocol\types\Experiments; use pocketmine\network\mcpe\protocol\types\LevelSettings; use pocketmine\network\mcpe\protocol\types\NetworkPermissions; use pocketmine\network\mcpe\protocol\types\PlayerMovementSettings; -use pocketmine\network\mcpe\protocol\types\PlayerMovementType; +use pocketmine\network\mcpe\protocol\types\ServerAuthMovementMode; use pocketmine\network\mcpe\protocol\types\SpawnSettings; use pocketmine\player\Player; use pocketmine\Server; @@ -98,7 +98,7 @@ class PreSpawnPacketHandler extends PacketHandler{ $this->server->getMotd(), "", false, - new PlayerMovementSettings(PlayerMovementType::SERVER_AUTHORITATIVE_V1, 0, false), + new PlayerMovementSettings(ServerAuthMovementMode::SERVER_AUTHORITATIVE_V2, 0, false), 0, 0, "", diff --git a/src/network/mcpe/handler/ResourcePacksPacketHandler.php b/src/network/mcpe/handler/ResourcePacksPacketHandler.php index 5f7fb0e4b..5e2671394 100644 --- a/src/network/mcpe/handler/ResourcePacksPacketHandler.php +++ b/src/network/mcpe/handler/ResourcePacksPacketHandler.php @@ -117,8 +117,7 @@ class ResourcePacksPacketHandler extends PacketHandler{ resourcePackEntries: $resourcePackEntries, mustAccept: $this->mustAccept, hasAddons: false, - hasScripts: false, - cdnUrls: [] + hasScripts: false )); $this->session->getLogger()->debug("Waiting for client to accept resource packs"); } diff --git a/tools/generate-bedrock-data-from-packets.php b/tools/generate-bedrock-data-from-packets.php index 16c3062b8..0cb5ac366 100644 --- a/tools/generate-bedrock-data-from-packets.php +++ b/tools/generate-bedrock-data-from-packets.php @@ -399,7 +399,7 @@ class ParserPacketHandler extends PacketHandler{ CraftingDataPacket::ENTRY_FURNACE => "smelting", CraftingDataPacket::ENTRY_FURNACE_DATA => "smelting", CraftingDataPacket::ENTRY_MULTI => "special_hardcoded", - CraftingDataPacket::ENTRY_SHULKER_BOX => "shapeless_shulker_box", + CraftingDataPacket::ENTRY_USER_DATA_SHAPELESS => "shapeless_shulker_box", CraftingDataPacket::ENTRY_SHAPELESS_CHEMISTRY => "shapeless_chemistry", CraftingDataPacket::ENTRY_SHAPED_CHEMISTRY => "shaped_chemistry", CraftingDataPacket::ENTRY_SMITHING_TRANSFORM => "smithing", From d372af351afd945ff44e3597db32ce81b2310259 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 26 Oct 2024 15:40:22 +0100 Subject: [PATCH 3/9] Fix changelog typo --- changelogs/5.19.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/5.19.md b/changelogs/5.19.md index 57d322bf7..6768c38e5 100644 --- a/changelogs/5.19.md +++ b/changelogs/5.19.md @@ -1,5 +1,5 @@ # 5.19.0 -Released 21tst September 2024. +Released 21st September 2024. **For Minecraft: Bedrock Edition 1.21.30** From 414e8acf8c6d451e2614201a5dabc0b2f2887486 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 26 Oct 2024 15:42:43 +0100 Subject: [PATCH 4/9] Release 5.20.0 --- changelogs/5.20.md | 19 +++++++++++++++++++ src/VersionInfo.php | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 changelogs/5.20.md diff --git a/changelogs/5.20.md b/changelogs/5.20.md new file mode 100644 index 000000000..8d7e971d9 --- /dev/null +++ b/changelogs/5.20.md @@ -0,0 +1,19 @@ +# 5.20.0 +Released 26th October 2024. + +**For Minecraft: Bedrock Edition 1.21.40** + +This is a support release for Minecraft: Bedrock Edition 1.21.40. + +**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace. +Do not update plugin minimum API versions unless you need new features added in this release. + +**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.** +Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly. + +## General +- Added support for Minecraft: Bedrock Edition 1.21.40. +- Removed support for earlier versions. + +## Fixes +- Fixed a bug in `tools/generate-blockstate-upgrade-schema.php` that caused it to fail on 1.21.40 with the new mushroom block changes. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index b2d2fe4ab..b61df1001 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "5.19.1"; - public const IS_DEVELOPMENT_BUILD = true; + public const BASE_VERSION = "5.20.0"; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; /** From e7d8d99ca6086111a607cc79a8e8e64e6532df24 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 26 Oct 2024 15:42:43 +0100 Subject: [PATCH 5/9] 5.20.1 is next --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index b61df1001..11c5b1c88 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "5.20.0"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "5.20.1"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; /** From 8ef5e737de5689ba83a9bf66b6efa147171452ce Mon Sep 17 00:00:00 2001 From: Dries C Date: Sun, 27 Oct 2024 02:29:34 +0200 Subject: [PATCH 6/9] Temporary resolve loading old skulls from storage (#6476) --- .../bedrock/item/upgrade/ItemDataUpgrader.php | 15 +++++++++++++++ src/world/format/io/GlobalItemDataHandlers.php | 6 +++++- src/world/format/io/data/BedrockWorldData.php | 6 +++--- src/world/format/io/leveldb/ChunkVersion.php | 1 + src/world/format/io/leveldb/LevelDB.php | 4 +++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/data/bedrock/item/upgrade/ItemDataUpgrader.php b/src/data/bedrock/item/upgrade/ItemDataUpgrader.php index d7d097de8..7b34ffcb6 100644 --- a/src/data/bedrock/item/upgrade/ItemDataUpgrader.php +++ b/src/data/bedrock/item/upgrade/ItemDataUpgrader.php @@ -25,6 +25,7 @@ namespace pocketmine\data\bedrock\item\upgrade; use pocketmine\data\bedrock\block\BlockStateDeserializeException; use pocketmine\data\bedrock\block\upgrade\BlockDataUpgrader; +use pocketmine\data\bedrock\item\BlockItemIdMap; use pocketmine\data\bedrock\item\SavedItemData; use pocketmine\data\bedrock\item\SavedItemStackData; use pocketmine\data\SavedDataLoadingException; @@ -35,6 +36,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; +use pocketmine\network\mcpe\convert\BlockStateDictionary; use pocketmine\utils\Binary; use function assert; @@ -46,6 +48,8 @@ final class ItemDataUpgrader{ private LegacyItemIdToStringIdMap $legacyIntToStringIdMap, private R12ItemIdToBlockIdMap $r12ItemIdToBlockIdMap, private BlockDataUpgrader $blockDataUpgrader, + private BlockItemIdMap $blockItemIdMap, + private BlockStateDictionary $blockStateDictionary ){} /** @@ -148,6 +152,17 @@ final class ItemDataUpgrader{ [$newNameId, $newMeta] = $this->idMetaUpgrader->upgrade($rawNameId, $meta); + //TODO: Dirty hack to load old skulls from disk: Put this into item upgrade schema's before Mojang makes something with a non 0 default state + if($blockStateData === null && ($blockId = $this->blockItemIdMap->lookupBlockId($newNameId)) !== null){ + $networkRuntimeId = $this->blockStateDictionary->lookupStateIdFromIdMeta($blockId, 0); + + if($networkRuntimeId === null){ + throw new SavedDataLoadingException("Failed to find blockstate for blockitem $newNameId"); + } + + $blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkRuntimeId); + } + //TODO: this won't account for spawn eggs from before 1.16.100 - perhaps we're lucky and they just left the meta in there anyway? //TODO: read version from VersionInfo::TAG_WORLD_DATA_VERSION - we may need it to fix up old items diff --git a/src/world/format/io/GlobalItemDataHandlers.php b/src/world/format/io/GlobalItemDataHandlers.php index ea5568c7c..f62258478 100644 --- a/src/world/format/io/GlobalItemDataHandlers.php +++ b/src/world/format/io/GlobalItemDataHandlers.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\world\format\io; +use pocketmine\data\bedrock\item\BlockItemIdMap; use pocketmine\data\bedrock\item\ItemDeserializer; use pocketmine\data\bedrock\item\ItemSerializer; use pocketmine\data\bedrock\item\upgrade\ItemDataUpgrader; @@ -30,6 +31,7 @@ use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgrader; use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgradeSchemaUtils; use pocketmine\data\bedrock\item\upgrade\LegacyItemIdToStringIdMap; use pocketmine\data\bedrock\item\upgrade\R12ItemIdToBlockIdMap; +use pocketmine\network\mcpe\convert\TypeConverter; use Symfony\Component\Filesystem\Path; use const PHP_INT_MAX; use const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH; @@ -54,7 +56,9 @@ final class GlobalItemDataHandlers{ new ItemIdMetaUpgrader(ItemIdMetaUpgradeSchemaUtils::loadSchemas(Path::join(BEDROCK_ITEM_UPGRADE_SCHEMA_PATH, 'id_meta_upgrade_schema'), PHP_INT_MAX)), LegacyItemIdToStringIdMap::getInstance(), R12ItemIdToBlockIdMap::getInstance(), - GlobalBlockStateHandlers::getUpgrader() + GlobalBlockStateHandlers::getUpgrader(), + BlockItemIdMap::getInstance(), + TypeConverter::getInstance()->getBlockTranslator()->getBlockStateDictionary() ); } } diff --git a/src/world/format/io/data/BedrockWorldData.php b/src/world/format/io/data/BedrockWorldData.php index 1612e7d84..b2e079124 100644 --- a/src/world/format/io/data/BedrockWorldData.php +++ b/src/world/format/io/data/BedrockWorldData.php @@ -51,12 +51,12 @@ use function time; class BedrockWorldData extends BaseNbtWorldData{ public const CURRENT_STORAGE_VERSION = 10; - public const CURRENT_STORAGE_NETWORK_VERSION = 729; + public const CURRENT_STORAGE_NETWORK_VERSION = 748; public const CURRENT_CLIENT_VERSION_TARGET = [ 1, //major 21, //minor - 30, //patch - 3, //revision + 40, //patch + 1, //revision 0 //is beta ]; diff --git a/src/world/format/io/leveldb/ChunkVersion.php b/src/world/format/io/leveldb/ChunkVersion.php index e399570de..a69e4ff45 100644 --- a/src/world/format/io/leveldb/ChunkVersion.php +++ b/src/world/format/io/leveldb/ChunkVersion.php @@ -71,4 +71,5 @@ final class ChunkVersion{ public const v1_18_0_24_unused = 38; public const v1_18_0_25_beta = 39; public const v1_18_30 = 40; + public const v1_21_40 = 41; } diff --git a/src/world/format/io/leveldb/LevelDB.php b/src/world/format/io/leveldb/LevelDB.php index 20b55922c..dda489d31 100644 --- a/src/world/format/io/leveldb/LevelDB.php +++ b/src/world/format/io/leveldb/LevelDB.php @@ -78,7 +78,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{ protected const ENTRY_FLAT_WORLD_LAYERS = "game_flatworldlayers"; - protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_18_30; + protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_21_40; protected const CURRENT_LEVEL_SUBCHUNK_VERSION = SubChunkVersion::PALETTED_MULTI; private const CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET = 4; @@ -654,6 +654,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{ $hasBeenUpgraded = $chunkVersion < self::CURRENT_LEVEL_CHUNK_VERSION; switch($chunkVersion){ + case ChunkVersion::v1_21_40: + //TODO: BiomeStates became shorts instead of bytes case ChunkVersion::v1_18_30: case ChunkVersion::v1_18_0_25_beta: case ChunkVersion::v1_18_0_24_unused: From 0065fe649fa0d1e90d618a650e5b27cb1e89bca6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 31 Oct 2024 13:52:15 +0000 Subject: [PATCH 7/9] New release workflow triggered by the merge of a PR changing IS_DEVELOPMENT_BUILD to false This is more streamlined than the previous approach, and works better for a world where 1 person isn't doing all the work. Now, the flow is simpler: - Do changes (e.g. protocol update), changelog & set IS_DEVELOPMENT_BUILD to false all in a single PR, which can be squash-merged if desired - Once the PR is merged, a draft release will be prepared - RestrictedActions will automatically set IS_DEVELOPMENT_BUILD back to true and bump the version - Tag will be created when the release is published Previously, multiple PRs might be needed, and the PR containing the release changelog couldn't be squash-merged. Manual intervention was also required to create a tag and prepare a release. This PR also includes new CI checks to check for basic errors like forgotten changelog files to ensure changelog links work correctly. Note: Only PRs from PMMP Team members with **write** access to the repository can trigger release generation. Random people cannot trigger release generation by sending PRs. --- .github/workflows/draft-release-from-pr.yml | 65 +++++++++++ .github/workflows/draft-release-from-tag.yml | 13 +++ .github/workflows/draft-release-pr-check.yml | 111 +++++++++++++++++++ .github/workflows/draft-release.yml | 31 ++++-- build/dump-version-info.php | 86 ++++++++++++++ build/make-release.php | 38 ++++--- phpstan.neon.dist | 1 + 7 files changed, 321 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/draft-release-from-pr.yml create mode 100644 .github/workflows/draft-release-from-tag.yml create mode 100644 .github/workflows/draft-release-pr-check.yml create mode 100644 build/dump-version-info.php diff --git a/.github/workflows/draft-release-from-pr.yml b/.github/workflows/draft-release-from-pr.yml new file mode 100644 index 000000000..3936a2649 --- /dev/null +++ b/.github/workflows/draft-release-from-pr.yml @@ -0,0 +1,65 @@ +name: Draft release from PR + +on: + #presume that pull_request_target is safe at this point, since the PR was approved and merged + #we need write access to prepare the release & create comments + pull_request_target: + types: + - closed + branches: + - stable + - minor-next + - major-next + - "legacy/*" + paths: + - "src/VersionInfo.php" + +jobs: + check: + name: Check release + uses: ./.github/workflows/draft-release-pr-check.yml + + draft: + name: Create GitHub draft release + needs: [check] + if: needs.check.outputs.valid == 'true' + + uses: ./.github/workflows/draft-release.yml + + post-draft-url-comment: + name: Post draft release URL as comment + needs: [draft] + + runs-on: ubuntu-20.04 + + steps: + - name: Post draft release URL on PR + uses: thollander/actions-comment-pull-request@v2 + with: + message: "[Draft release ${{ needs.draft.outputs.version }}](${{ needs.draft.outputs.draft-url }}) has been created for commit ${{ github.sha }}. Please review and publish it." + + trigger-post-release-workflow: + name: Trigger post-release RestrictedActions workflow + # Not sure if needs is actually needed here + needs: [check] + if: needs.check.outputs.valid == 'true' + + runs-on: ubuntu-20.04 + + steps: + - name: Generate access token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }} + private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }} + owner: ${{ github.repository_owner }} + repositories: RestrictedActions + + - name: Dispatch post-release restricted action + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + repository: ${{ github.repository_owner }}/RestrictedActions + event-type: pocketmine_mp_post_release + client-payload: '{"branch": "${{ github.ref }}"}' diff --git a/.github/workflows/draft-release-from-tag.yml b/.github/workflows/draft-release-from-tag.yml new file mode 100644 index 000000000..f7a5df544 --- /dev/null +++ b/.github/workflows/draft-release-from-tag.yml @@ -0,0 +1,13 @@ +#Allows creating a release by pushing a tag +#This might be useful for retroactive releases +name: Draft release from git tag + +on: + push: + tags: "*" + +jobs: + draft: + name: Create GitHub draft release + if: "startsWith(github.event.head_commit.message, 'Release ')" + uses: ./.github/workflows/draft-release.yml diff --git a/.github/workflows/draft-release-pr-check.yml b/.github/workflows/draft-release-pr-check.yml new file mode 100644 index 000000000..4c8d0f685 --- /dev/null +++ b/.github/workflows/draft-release-pr-check.yml @@ -0,0 +1,111 @@ +name: Release PR checks + +on: + #do checks on every PR update + pull_request: + branches: + - stable + - minor-next + - major-next + - "legacy/*" + paths: + - "src/VersionInfo.php" + + #allow this workflow to be invoked on PR merge, prior to creating the release + workflow_call: + outputs: + valid: + description: Whether this commit is valid for release + value: ${{ jobs.check-intent.outputs.valid && jobs.check-validity.result == 'success' }} + +permissions: + contents: read #for user access check + +jobs: + check-intent: + name: Check release trigger + runs-on: ubuntu-20.04 + + outputs: + valid: ${{ steps.validate.outputs.DEV_BUILD == 'false' }} + + steps: + - uses: actions/checkout@v4 + + - name: Check IS_DEVELOPMENT_BUILD flag + id: validate + run: | + echo DEV_BUILD=$(sed -n "s/^\s*public const IS_DEVELOPMENT_BUILD = \(true\|false\);$/\1/p" src/VersionInfo.php) >> $GITHUB_OUTPUT + + check-validity: + name: Validate release info + needs: [check-intent] + #don't do these checks if this isn't a release - we don't want to generate unnecessary failed statuses + if: needs.check-intent.outputs.valid == 'true' + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: 8.2 + + - name: Restore Composer package cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/composer/files + ~/.cache/composer/vcs + key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}" + restore-keys: | + composer-v2-cache- + + - name: Install Composer dependencies + run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs + + - name: Check author permissions + id: check-permission + uses: actions-cool/check-user-permission@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + require: write + username: ${{ github.event.pull_request.user.login }} + #technically this would be fine for dependabot but generally bots don't count as team members + check-bot: true + + - name: Abort if user permissions are insufficient + #user doesn't have permission or is a bot + if: steps.check-permission.outputs.require-result != 'true' || steps.check-permission.outputs.check-result != 'false' + run: | + echo "::error::This user is not authorized to trigger releases" + exit 1 + + - name: Check changelog file is present + id: file-presence + run: | + CHANGELOG_FILE="changelogs/$(php build/dump-version-info.php changelog_file_name)" + if [ ! -f "${{ github.workspace }}/$CHANGELOG_FILE" ]; then + echo "::error::$CHANGELOG_FILE does not exist" + exit 1 + fi + echo FILE="$CHANGELOG_FILE" >> $GITHUB_OUTPUT + + - name: Check header is present in changelog file + run: | + FILE="${{ steps.file-presence.outputs.FILE }}" + VERSION="$(php build/dump-version-info.php base_version)" + if ! grep -Fqx "# $VERSION" "${{ github.workspace }}/$FILE"; then + echo "::error::Header for $VERSION not found in $FILE" + exit 1 + fi + + - name: Check version is valid for the selected channel + run: | + CHANNEL="$(php build/dump-version-info.php channel)" + if [ "$(php build/dump-version-info.php suffix_valid)" != "true" ]; then + echo "::error::Version $(php build/dump-version-info.php base_version) is not allowed on the $CHANNEL channel" + exit 1 + fi diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index c47a4399b..0a07a738b 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,19 +1,29 @@ name: Draft release on: - push: - tags: "*" + workflow_call: + outputs: + draft-url: + description: 'The URL of the draft release' + value: ${{ jobs.draft.outputs.draft-url }} + version: + description: 'PocketMine-MP version' + value: ${{ jobs.draft.outputs.version }} jobs: draft: name: Create GitHub draft release - if: "startsWith(github.event.head_commit.message, 'Release ')" + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: php-version: [8.2] + outputs: + draft-url: ${{ steps.create-draft.outputs.html_url }} + version: ${{ steps.get-pm-version.outputs.PM_VERSION }} + steps: - uses: actions/checkout@v4 with: @@ -53,12 +63,11 @@ jobs: - name: Get PocketMine-MP release version id: get-pm-version run: | - echo PM_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BASE_VERSION;') >> $GITHUB_OUTPUT - echo MCPE_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK;') >> $GITHUB_OUTPUT - echo PM_VERSION_SHORT=$(php -r 'require "vendor/autoload.php"; $v = explode(".", \pocketmine\VersionInfo::BASE_VERSION); array_pop($v); echo implode(".", $v);') >> $GITHUB_OUTPUT - echo PM_VERSION_MD=$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);') >> $GITHUB_OUTPUT - echo CHANGELOG_SUFFIX=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "" : "-" . \pocketmine\VersionInfo::BUILD_CHANNEL;') >> $GITHUB_OUTPUT - echo PRERELEASE=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "false" : "true";') >> $GITHUB_OUTPUT + echo PM_VERSION=$(php build/dump-version-info.php base_version) >> $GITHUB_OUTPUT + echo MCPE_VERSION=$(php build/dump-version-info.php mcpe_version) >> $GITHUB_OUTPUT + echo CHANGELOG_FILE_NAME=$(php build/dump-version-info.php changelog_file_name) >> $GITHUB_OUTPUT + echo CHANGELOG_MD_HEADER=$(php build/dump-version-info.php changelog_md_header) >> $GITHUB_OUTPUT + echo PRERELEASE=$(php build/dump-version-info.php prerelease) >> $GITHUB_OUTPUT - name: Generate PHP binary download URL id: php-binary-url @@ -91,6 +100,7 @@ jobs: - name: Create draft release uses: ncipollo/release-action@v1.14.0 + id: create-draft with: artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json,${{ github.workspace }}/core-permissions.rst commit: ${{ github.sha }} @@ -99,9 +109,10 @@ jobs: name: PocketMine-MP ${{ steps.get-pm-version.outputs.PM_VERSION }} tag: ${{ steps.get-pm-version.outputs.PM_VERSION }} token: ${{ secrets.GITHUB_TOKEN }} + skipIfReleaseExists: true #for release PRs, tags will be created on release publish and trigger the tag release workflow - don't create a second draft body: | **For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}** - Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}${{ steps.get-pm-version.outputs.CHANGELOG_SUFFIX }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details. + Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.CHANGELOG_FILE_NAME }}#${{ steps.get-pm-version.outputs.CHANGELOG_MD_HEADER }}) for details. :information_source: Download the recommended PHP binary [here](${{ steps.php-binary-url.outputs.PHP_BINARY_URL }}). diff --git a/build/dump-version-info.php b/build/dump-version-info.php new file mode 100644 index 000000000..8898d7cab --- /dev/null +++ b/build/dump-version-info.php @@ -0,0 +1,86 @@ + $options + */ +$options = [ + "base_version" => VersionInfo::BASE_VERSION, + "mcpe_version" => ProtocolInfo::MINECRAFT_VERSION_NETWORK, + "is_dev" => VersionInfo::IS_DEVELOPMENT_BUILD, + "changelog_file_name" => function() : string{ + $version = VersionInfo::VERSION(); + $result = $version->getMajor() . "." . $version->getMinor(); + $suffix = $version->getSuffix(); + if($suffix !== ""){ + if(preg_match('/^([A-Za-z]+)(\d+)$/', $suffix, $matches) !== 1){ + fwrite(STDERR, "error: invalid current version suffix \"$suffix\"; aborting" . PHP_EOL); + exit(1); + } + $baseSuffix = $matches[1]; + $result .= "-" . strtolower($baseSuffix); + } + return $result . ".md"; + }, + "changelog_md_header" => fn() : string => str_replace(".", "", VersionInfo::BASE_VERSION), + "prerelease" => fn() : bool => VersionInfo::VERSION()->getSuffix() !== "", + "channel" => VersionInfo::BUILD_CHANNEL, + "suffix_valid" => function() : bool{ + //TODO: maybe this should be put into its own script? + $suffix = VersionInfo::VERSION()->getSuffix(); + if(VersionInfo::BUILD_CHANNEL === "stable"){ + //stable builds may not have suffixes + return $suffix === ""; + } + if(VersionInfo::BUILD_CHANNEL === "alpha" || VersionInfo::BUILD_CHANNEL === "beta"){ + $upperChannel = strtoupper(VersionInfo::BUILD_CHANNEL); + $upperSuffix = strtoupper($suffix); + return str_starts_with($upperSuffix, $upperChannel) && is_numeric(substr($upperSuffix, strlen($upperChannel))); + } + return true; + } +]; +if(count($argv) !== 2 || !isset($options[$argv[1]])){ + fwrite(STDERR, "Please provide an option (one of: " . implode(", ", array_keys($options)) . PHP_EOL); + exit(1); +} + +$result = $options[$argv[1]]; +if($result instanceof Closure){ + $result = $result(); +} +if(is_bool($result)){ + echo $result ? "true" : "false"; +}else{ + echo $result; +} diff --git a/build/make-release.php b/build/make-release.php index 7a570eb35..741f9d787 100644 --- a/build/make-release.php +++ b/build/make-release.php @@ -86,7 +86,8 @@ function systemWrapper(string $command, string $errorMessage) : void{ function main() : void{ $filteredOpts = []; - foreach(Utils::stringifyKeys(getopt("", ["current:", "next:", "channel:", "help"])) as $optName => $optValue){ + $postCommitOnly = false; + foreach(Utils::stringifyKeys(getopt("", ["current:", "next:", "channel:", "help", "post"])) as $optName => $optValue){ if($optName === "help"){ fwrite(STDOUT, "Options:\n"); @@ -96,6 +97,10 @@ function main() : void{ } exit(0); } + if($optName === "post"){ + $postCommitOnly = true; + continue; + } if(!is_string($optValue)){ fwrite(STDERR, "--$optName expects exactly 1 value\n"); exit(1); @@ -141,20 +146,25 @@ function main() : void{ $channel ??= "stable"; } - echo "About to tag version $currentVer. Next version will be $nextVer.\n"; - echo "$currentVer will be published on release channel \"$channel\".\n"; - echo "please add appropriate notes to the changelog and press enter..."; - fgets(STDIN); - systemWrapper('git add "' . dirname(__DIR__) . '/changelogs"', "failed to stage changelog changes"); - system('git diff --cached --quiet "' . dirname(__DIR__) . '/changelogs"', $result); - if($result === 0){ - echo "error: no changelog changes detected; aborting\n"; - exit(1); - } $versionInfoPath = dirname(__DIR__) . '/src/VersionInfo.php'; - replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel); - systemWrapper('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"', "failed to create release commit"); - systemWrapper('git tag ' . $currentVer->getBaseVersion(), "failed to create release tag"); + + if($postCommitOnly){ + echo "Skipping release commit & tag. Bumping to next version $nextVer directly.\n"; + }else{ + echo "About to tag version $currentVer. Next version will be $nextVer.\n"; + echo "$currentVer will be published on release channel \"$channel\".\n"; + echo "please add appropriate notes to the changelog and press enter..."; + fgets(STDIN); + systemWrapper('git add "' . dirname(__DIR__) . '/changelogs"', "failed to stage changelog changes"); + system('git diff --cached --quiet "' . dirname(__DIR__) . '/changelogs"', $result); + if($result === 0){ + echo "error: no changelog changes detected; aborting\n"; + exit(1); + } + replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel); + systemWrapper('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"', "failed to create release commit"); + systemWrapper('git tag ' . $currentVer->getBaseVersion(), "failed to create release tag"); + } replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, $channel); systemWrapper('git add "' . $versionInfoPath . '"', "failed to stage changes for post-release commit"); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2fde67d6c..b96e4348d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -40,6 +40,7 @@ parameters: - build/php dynamicConstantNames: - pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD + - pocketmine\VersionInfo::BUILD_CHANNEL - pocketmine\DEBUG - pocketmine\IS_DEVELOPMENT_BUILD stubFiles: From 94dff744941d1b9770bd96ccdcf890298f1fd1a4 Mon Sep 17 00:00:00 2001 From: "Dylan T." Date: Thu, 31 Oct 2024 14:35:42 +0000 Subject: [PATCH 8/9] Prepare 5.20.1 release (#6479) --- changelogs/5.20.md | 6 ++++++ src/VersionInfo.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelogs/5.20.md b/changelogs/5.20.md index 8d7e971d9..b0da701d6 100644 --- a/changelogs/5.20.md +++ b/changelogs/5.20.md @@ -17,3 +17,9 @@ Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if ## Fixes - Fixed a bug in `tools/generate-blockstate-upgrade-schema.php` that caused it to fail on 1.21.40 with the new mushroom block changes. + +# 5.20.1 +Released 31st October 2024. + +## Fixes +- Workaround old mob heads in world saves not being upgraded correctly and causing crashes. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 11c5b1c88..20d0154c7 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -32,7 +32,7 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; public const BASE_VERSION = "5.20.1"; - public const IS_DEVELOPMENT_BUILD = true; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; /** From 0376e37966c2bddc8466f9b64aad7776656d0eaa Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 31 Oct 2024 14:38:30 +0000 Subject: [PATCH 9/9] 5.20.2 is next Commit created by: https://github.com/pmmp/RestrictedActions/actions/runs/11614028030 --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 20d0154c7..5de1f5a05 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "5.20.1"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "5.20.2"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; /**