mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Added cartography and smithing tables
these have working inventories, and their crafting menus will 'just work' once the items for the associated recipes have been implemented (maps, netherite).
This commit is contained in:
parent
91719051e2
commit
eb8fb63409
12
composer.lock
generated
12
composer.lock
generated
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
44
src/block/CartographyTable.php
Normal file
44
src/block/CartographyTable.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\inventory\CartographyTableInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
final class CartographyTable extends Opaque{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$player->setCurrentWindow(new CartographyTableInventory($this->position));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
44
src/block/SmithingTable.php
Normal file
44
src/block/SmithingTable.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\inventory\SmithingTableInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
final class SmithingTable extends Opaque{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$player->setCurrentWindow(new SmithingTableInventory($this->position));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -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()));
|
||||
|
37
src/block/inventory/CartographyTableInventory.php
Normal file
37
src/block/inventory/CartographyTableInventory.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class CartographyTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(2);
|
||||
}
|
||||
}
|
37
src/block/inventory/SmithingTableInventory.php
Normal file
37
src/block/inventory/SmithingTableInventory.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
final class SmithingTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{
|
||||
use BlockInventoryTrait;
|
||||
|
||||
public function __construct(Position $holder){
|
||||
$this->holder = $holder;
|
||||
parent::__construct(2);
|
||||
}
|
||||
}
|
@ -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){
|
||||
|
@ -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")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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())
|
||||
|
@ -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)];
|
||||
|
2
src/network/mcpe/cache/CraftingDataCache.php
vendored
2
src/network/mcpe/cache/CraftingDataCache.php
vendored
@ -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(
|
||||
|
@ -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){
|
||||
|
Loading…
x
Reference in New Issue
Block a user