diff --git a/composer.lock b/composer.lock index 0544435b1..8f85da457 100644 --- a/composer.lock +++ b/composer.lock @@ -329,16 +329,16 @@ }, { "name": "pocketmine/bedrock-protocol", - "version": "11.0.0+bedrock-1.19.10", + "version": "11.0.3+bedrock-1.19.10", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "705f928bd010ba093d8781d20006e4cd5f79f335" + "reference": "18879218f9d05685ab6f8f68df4cb9c548978657" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/705f928bd010ba093d8781d20006e4cd5f79f335", - "reference": "705f928bd010ba093d8781d20006e4cd5f79f335", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/18879218f9d05685ab6f8f68df4cb9c548978657", + "reference": "18879218f9d05685ab6f8f68df4cb9c548978657", "shasum": "" }, "require": { @@ -370,9 +370,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/11.0.0+bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockProtocol/tree/11.0.3+bedrock-1.19.10" }, - "time": "2022-07-12T23:47:47+00:00" + "time": "2022-07-14T16:54:49+00:00" }, { "name": "pocketmine/binaryutils", diff --git a/src/block/BlockTypeIds.php b/src/block/BlockTypeIds.php index 11c6b87da..6958efb54 100644 --- a/src/block/BlockTypeIds.php +++ b/src/block/BlockTypeIds.php @@ -690,6 +690,8 @@ final class BlockTypeIds{ public const CAKE_WITH_DYED_CANDLE = 10663; public const WITHER_ROSE = 10664; public const HANGING_ROOTS = 10665; + public const CARTOGRAPHY_TABLE = 10666; + public const SMITHING_TABLE = 10667; - public const FIRST_UNUSED_BLOCK_ID = 10666; + public const FIRST_UNUSED_BLOCK_ID = 10668; } diff --git a/src/block/CartographyTable.php b/src/block/CartographyTable.php new file mode 100644 index 000000000..195c18070 --- /dev/null +++ b/src/block/CartographyTable.php @@ -0,0 +1,44 @@ +setCurrentWindow(new CartographyTableInventory($this->position)); + } + + return true; + } + + public function getFuelTime() : int{ + return 300; + } +} diff --git a/src/block/SmithingTable.php b/src/block/SmithingTable.php new file mode 100644 index 000000000..5c4976cae --- /dev/null +++ b/src/block/SmithingTable.php @@ -0,0 +1,44 @@ +setCurrentWindow(new SmithingTableInventory($this->position)); + } + + return true; + } + + public function getFuelTime() : int{ + return 300; + } +} diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index a3d0514e4..3939bb3b7 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -141,6 +141,7 @@ use function mb_strtolower; * @method static Candle CANDLE() * @method static Carpet CARPET() * @method static Carrot CARROTS() + * @method static CartographyTable CARTOGRAPHY_TABLE() * @method static CarvedPumpkin CARVED_PUMPKIN() * @method static ChemicalHeat CHEMICAL_HEAT() * @method static Chest CHEST() @@ -612,6 +613,7 @@ use function mb_strtolower; * @method static Opaque SHROOMLIGHT() * @method static ShulkerBox SHULKER_BOX() * @method static Slime SLIME() + * @method static SmithingTable SMITHING_TABLE() * @method static Furnace SMOKER() * @method static Opaque SMOOTH_BASALT() * @method static Opaque SMOOTH_QUARTZ() @@ -1158,6 +1160,7 @@ final class VanillaBlocks{ self::registerBlocksR17(); self::registerMudBlocks(); + self::registerCraftingTables(); self::registerOres(); self::registerWoodenBlocks(); } @@ -1356,6 +1359,13 @@ final class VanillaBlocks{ self::register("nether_gold_ore", new NetherGoldOre(new BID(Ids::NETHER_GOLD_ORE), "Nether Gold Ore", $netherrackOreBreakInfo)); } + private static function registerCraftingTables() : void{ + //TODO: this is the same for all wooden crafting blocks + $craftingBlockBreakInfo = new BreakInfo(2.5, ToolType::AXE); + self::register("cartography_table", new CartographyTable(new BID(Ids::CARTOGRAPHY_TABLE), "Cartography Table", $craftingBlockBreakInfo)); + self::register("smithing_table", new SmithingTable(new BID(Ids::SMITHING_TABLE), "Smithing Table", $craftingBlockBreakInfo)); + } + private static function registerBlocksR13() : void{ self::register("light", new Light(new BID(Ids::LIGHT), "Light Block", BreakInfo::indestructible())); self::register("wither_rose", new WitherRose(new BID(Ids::WITHER_ROSE), "Wither Rose", BreakInfo::instant())); diff --git a/src/block/inventory/CartographyTableInventory.php b/src/block/inventory/CartographyTableInventory.php new file mode 100644 index 000000000..7bd9146ac --- /dev/null +++ b/src/block/inventory/CartographyTableInventory.php @@ -0,0 +1,37 @@ +holder = $holder; + parent::__construct(2); + } +} diff --git a/src/block/inventory/SmithingTableInventory.php b/src/block/inventory/SmithingTableInventory.php new file mode 100644 index 000000000..a01b80cad --- /dev/null +++ b/src/block/inventory/SmithingTableInventory.php @@ -0,0 +1,37 @@ +holder = $holder; + parent::__construct(2); + } +} diff --git a/src/crafting/CraftingManagerFromDataHelper.php b/src/crafting/CraftingManagerFromDataHelper.php index 74fe74a7f..e48b20ec5 100644 --- a/src/crafting/CraftingManagerFromDataHelper.php +++ b/src/crafting/CraftingManagerFromDataHelper.php @@ -213,7 +213,8 @@ final class CraftingManagerFromDataHelper{ $recipeType = match($recipe->block){ "crafting_table" => ShapelessRecipeType::CRAFTING(), "stonecutter" => ShapelessRecipeType::STONECUTTER(), - //TODO: Cartography Table + "smithing_table" => ShapelessRecipeType::SMITHING(), + "cartography_table" => ShapelessRecipeType::CARTOGRAPHY(), default => null }; if($recipeType === null){ diff --git a/src/crafting/ShapelessRecipeType.php b/src/crafting/ShapelessRecipeType.php index e7d3242d5..b115c22f4 100644 --- a/src/crafting/ShapelessRecipeType.php +++ b/src/crafting/ShapelessRecipeType.php @@ -31,7 +31,9 @@ use pocketmine\utils\EnumTrait; * @see build/generate-registry-annotations.php * @generate-registry-docblock * + * @method static ShapelessRecipeType CARTOGRAPHY() * @method static ShapelessRecipeType CRAFTING() + * @method static ShapelessRecipeType SMITHING() * @method static ShapelessRecipeType STONECUTTER() */ final class ShapelessRecipeType{ @@ -40,7 +42,9 @@ final class ShapelessRecipeType{ protected static function setup() : void{ self::registerAll( new self("crafting"), - new self("stonecutter") + new self("stonecutter"), + new self("smithing"), + new self("cartography") ); } } diff --git a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php index 7ca09189c..039b4aab1 100644 --- a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php +++ b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php @@ -443,6 +443,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeColor($block->getColor()); }); $this->map(Blocks::CARROTS(), fn(Carrot $block) => Helper::encodeCrops($block, new Writer(Ids::CARROTS))); + $this->mapSimple(Blocks::CARTOGRAPHY_TABLE(), Ids::CARTOGRAPHY_TABLE); $this->map(Blocks::CARVED_PUMPKIN(), function(CarvedPumpkin $block) : Writer{ return Writer::create(Ids::CARVED_PUMPKIN) ->writeLegacyHorizontalFacing($block->getFacing()); @@ -1205,6 +1206,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::SHROOMLIGHT(), Ids::SHROOMLIGHT); $this->mapSimple(Blocks::SHULKER_BOX(), Ids::UNDYED_SHULKER_BOX); $this->mapSimple(Blocks::SLIME(), Ids::SLIME); + $this->mapSimple(Blocks::SMITHING_TABLE(), Ids::SMITHING_TABLE); $this->map(Blocks::SMOKER(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::SMOKER, Ids::LIT_SMOKER)); $this->mapSimple(Blocks::SMOOTH_BASALT(), Ids::SMOOTH_BASALT); $this->map(Blocks::SMOOTH_QUARTZ(), fn() => Helper::encodeQuartz(StringValues::CHISEL_TYPE_SMOOTH, Axis::Y)); diff --git a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php index 7ca7bbef7..27fa0da74 100644 --- a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php +++ b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php @@ -261,6 +261,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize ->setColor($in->readColor()); }); $this->map(Ids::CARROTS, fn(Reader $in) => Helper::decodeCrops(Blocks::CARROTS(), $in)); + $this->map(Ids::CARTOGRAPHY_TABLE, fn() => Blocks::CARTOGRAPHY_TABLE()); $this->map(Ids::CARVED_PUMPKIN, function(Reader $in) : Block{ return Blocks::CARVED_PUMPKIN() ->setFacing($in->readLegacyHorizontalFacing()); @@ -1055,6 +1056,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize ->setFacing($in->readFacingWithoutDown()); }); $this->map(Ids::SLIME, fn() => Blocks::SLIME()); + $this->map(Ids::SMITHING_TABLE, fn() => Blocks::SMITHING_TABLE()); $this->map(Ids::SMOKER, function(Reader $in) : Block{ return Blocks::SMOKER() ->setFacing($in->readHorizontalFacing()) diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index 4b7f870f8..723e02d13 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -26,11 +26,13 @@ namespace pocketmine\network\mcpe; use pocketmine\block\inventory\AnvilInventory; use pocketmine\block\inventory\BlockInventory; use pocketmine\block\inventory\BrewingStandInventory; +use pocketmine\block\inventory\CartographyTableInventory; use pocketmine\block\inventory\CraftingTableInventory; use pocketmine\block\inventory\EnchantInventory; use pocketmine\block\inventory\FurnaceInventory; use pocketmine\block\inventory\HopperInventory; use pocketmine\block\inventory\LoomInventory; +use pocketmine\block\inventory\SmithingTableInventory; use pocketmine\block\inventory\StonecutterInventory; use pocketmine\crafting\FurnaceType; use pocketmine\inventory\CreativeInventory; @@ -225,6 +227,8 @@ class InventoryManager{ $inv instanceof HopperInventory => WindowTypes::HOPPER, $inv instanceof CraftingTableInventory => WindowTypes::WORKBENCH, $inv instanceof StonecutterInventory => WindowTypes::STONECUTTER, + $inv instanceof CartographyTableInventory => WindowTypes::CARTOGRAPHY, + $inv instanceof SmithingTableInventory => WindowTypes::SMITHING_TABLE, default => WindowTypes::CONTAINER }; return [ContainerOpenPacket::blockInv($id, $windowType, $blockPosition)]; diff --git a/src/network/mcpe/cache/CraftingDataCache.php b/src/network/mcpe/cache/CraftingDataCache.php index 84ff5e739..740576521 100644 --- a/src/network/mcpe/cache/CraftingDataCache.php +++ b/src/network/mcpe/cache/CraftingDataCache.php @@ -86,6 +86,8 @@ final class CraftingDataCache{ $typeTag = match($recipe->getType()->id()){ ShapelessRecipeType::CRAFTING()->id() => CraftingRecipeBlockName::CRAFTING_TABLE, ShapelessRecipeType::STONECUTTER()->id() => CraftingRecipeBlockName::STONECUTTER, + ShapelessRecipeType::CARTOGRAPHY()->id() => CraftingRecipeBlockName::SMITHING_TABLE, + ShapelessRecipeType::SMITHING()->id() => CraftingRecipeBlockName::SMITHING_TABLE, default => throw new AssumptionFailedError("Unreachable"), }; $recipesWithTypeIds[] = new ProtocolShapelessRecipe( diff --git a/src/network/mcpe/convert/TypeConverter.php b/src/network/mcpe/convert/TypeConverter.php index 179fd8e8e..a0d4fcd8b 100644 --- a/src/network/mcpe/convert/TypeConverter.php +++ b/src/network/mcpe/convert/TypeConverter.php @@ -24,9 +24,11 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\convert; use pocketmine\block\inventory\AnvilInventory; +use pocketmine\block\inventory\CartographyTableInventory; use pocketmine\block\inventory\CraftingTableInventory; use pocketmine\block\inventory\EnchantInventory; use pocketmine\block\inventory\LoomInventory; +use pocketmine\block\inventory\SmithingTableInventory; use pocketmine\block\inventory\StonecutterInventory; use pocketmine\block\VanillaBlocks; use pocketmine\crafting\ExactRecipeIngredient; @@ -257,6 +259,8 @@ class TypeConverter{ $current instanceof LoomInventory => UIInventorySlotOffset::LOOM, $current instanceof StonecutterInventory => [UIInventorySlotOffset::STONE_CUTTER_INPUT => StonecutterInventory::SLOT_INPUT], $current instanceof CraftingTableInventory => UIInventorySlotOffset::CRAFTING3X3_INPUT, + $current instanceof CartographyTableInventory => UIInventorySlotOffset::CARTOGRAPHY_TABLE, + $current instanceof SmithingTableInventory => UIInventorySlotOffset::SMITHING_TABLE, default => null }; if($slotMap !== null){