Added Loom blocks

these don't support doing patterns yet, but their inventories work.
This commit is contained in:
Dylan K. Taylor
2021-04-29 19:51:09 +01:00
parent b33bf1f433
commit 593a8ac529
8 changed files with 115 additions and 2 deletions

View File

@ -29,6 +29,7 @@ use pocketmine\block\inventory\BrewingStandInventory;
use pocketmine\block\inventory\EnchantInventory;
use pocketmine\block\inventory\FurnaceInventory;
use pocketmine\block\inventory\HopperInventory;
use pocketmine\block\inventory\LoomInventory;
use pocketmine\inventory\CreativeInventory;
use pocketmine\inventory\Inventory;
use pocketmine\inventory\transaction\action\SlotChangeAction;
@ -161,6 +162,8 @@ class InventoryManager{
//if the class isn't final, not to mention being inflexible.
if($inv instanceof BlockInventory){
switch(true){
case $inv instanceof LoomInventory:
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::LOOM, $inv->getHolder())];
case $inv instanceof FurnaceInventory:
//TODO: specialized furnace types
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::FURNACE, $inv->getHolder())];

View File

@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\convert;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\inventory\AnvilInventory;
use pocketmine\block\inventory\EnchantInventory;
use pocketmine\block\inventory\LoomInventory;
use pocketmine\crafting\CraftingGrid;
use pocketmine\inventory\Inventory;
use pocketmine\inventory\transaction\action\CreateItemAction;
@ -266,7 +267,9 @@ class TypeConverter{
$this->mapUIInventory($pSlot, UIInventorySlotOffset::ANVIL, $current,
function(Inventory $i) : bool{ return $i instanceof AnvilInventory; }) ??
$this->mapUIInventory($pSlot, UIInventorySlotOffset::ENCHANTING_TABLE, $current,
function(Inventory $i) : bool{ return $i instanceof EnchantInventory; });
function(Inventory $i) : bool{ return $i instanceof EnchantInventory; }) ??
$this->mapUIInventory($pSlot, UIInventorySlotOffset::LOOM, $current,
fn(Inventory $i) => $i instanceof LoomInventory);
}
if($mapped === null){
throw new \UnexpectedValueException("Unmatched UI inventory slot offset $pSlot");

View File

@ -277,6 +277,7 @@ class InGamePacketHandler extends PacketHandler{
if($isCraftingPart){
if($this->craftingTransaction === null){
//TODO: this might not be crafting if there is a special inventory open (anvil, enchanting, loom etc)
$this->craftingTransaction = new CraftingTransaction($this->player, $this->player->getServer()->getCraftingManager(), $actions);
}else{
foreach($actions as $action){