mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Rewritten crafting, fixed #45
This commit is contained in:
@ -172,7 +172,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
return $this->player->handleCraftingEvent($packet);
|
||||
return true; //this is a broken useless packet, so we don't use it
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
|
@ -47,10 +47,16 @@ class InventoryTransactionPacket extends DataPacket{
|
||||
const USE_ITEM_ON_ENTITY_ACTION_INTERACT = 0;
|
||||
const USE_ITEM_ON_ENTITY_ACTION_ATTACK = 1;
|
||||
|
||||
|
||||
/** @var int */
|
||||
public $transactionType;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* NOTE: THIS FIELD DOES NOT EXIST IN THE PROTOCOL, it's merely used for convenience for PocketMine-MP to easily
|
||||
* determine whether we're doing a crafting transaction.
|
||||
*/
|
||||
public $isCraftingPart = false;
|
||||
|
||||
/** @var NetworkInventoryAction[] */
|
||||
public $actions = [];
|
||||
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
use pocketmine\inventory\transaction\action\CraftingTakeResultAction;
|
||||
use pocketmine\inventory\transaction\action\CraftingTransferMaterialAction;
|
||||
use pocketmine\inventory\transaction\action\CreativeInventoryAction;
|
||||
use pocketmine\inventory\transaction\action\DropItemAction;
|
||||
use pocketmine\inventory\transaction\action\InventoryAction;
|
||||
@ -108,6 +110,12 @@ class NetworkInventoryAction{
|
||||
break;
|
||||
case self::SOURCE_TODO:
|
||||
$this->windowId = $packet->getVarInt();
|
||||
switch($this->windowId){
|
||||
case self::SOURCE_TYPE_CRAFTING_USE_INGREDIENT:
|
||||
case self::SOURCE_TYPE_CRAFTING_RESULT:
|
||||
$packet->isCraftingPart = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -190,6 +198,10 @@ class NetworkInventoryAction{
|
||||
case self::SOURCE_TYPE_CRAFTING_REMOVE_INGREDIENT:
|
||||
$window = $player->getCraftingGrid();
|
||||
return new SlotChangeAction($window, $this->inventorySlot, $this->oldItem, $this->newItem);
|
||||
case self::SOURCE_TYPE_CRAFTING_RESULT:
|
||||
return new CraftingTakeResultAction($this->oldItem, $this->newItem);
|
||||
case self::SOURCE_TYPE_CRAFTING_USE_INGREDIENT:
|
||||
return new CraftingTransferMaterialAction($this->oldItem, $this->newItem, $this->inventorySlot);
|
||||
|
||||
case self::SOURCE_TYPE_CONTAINER_DROP_CONTENTS:
|
||||
//TODO: this type applies to all fake windows, not just crafting
|
||||
|
Reference in New Issue
Block a user