mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +00:00
Force-close the crafting window only when doing crafting transactions
otherwise the client will crash when using right-click on the recipe book
This commit is contained in:
parent
9bbebaa071
commit
ca401ec3f5
@ -50,20 +50,6 @@ class CraftingGrid extends BaseInventory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function sendContents($target) : void{
|
public function sendContents($target) : void{
|
||||||
if(!is_array($target)){
|
//no way to do this
|
||||||
$target = [$target];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: HACK!
|
|
||||||
* we can't resend the contents of this window, so we force the client to close it instead.
|
|
||||||
* So people don't whine about messy desync issues when someone cancels CraftItemEvent, or when a crafting
|
|
||||||
* transaction goes wrong.
|
|
||||||
*/
|
|
||||||
$pk = new ContainerClosePacket();
|
|
||||||
$pk->windowId = ContainerIds::NONE;
|
|
||||||
foreach($target as $player){
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,6 +28,8 @@ use pocketmine\inventory\BigCraftingGrid;
|
|||||||
use pocketmine\inventory\CraftingRecipe;
|
use pocketmine\inventory\CraftingRecipe;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\ItemFactory;
|
||||||
|
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class CraftingTransaction extends InventoryTransaction{
|
class CraftingTransaction extends InventoryTransaction{
|
||||||
@ -142,6 +144,20 @@ class CraftingTransaction extends InventoryTransaction{
|
|||||||
return !$ev->isCancelled();
|
return !$ev->isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function sendInventories() : void{
|
||||||
|
parent::sendInventories();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: HACK!
|
||||||
|
* we can't resend the contents of the crafting window, so we force the client to close it instead.
|
||||||
|
* So people don't whine about messy desync issues when someone cancels CraftItemEvent, or when a crafting
|
||||||
|
* transaction goes wrong.
|
||||||
|
*/
|
||||||
|
$pk = new ContainerClosePacket();
|
||||||
|
$pk->windowId = ContainerIds::NONE;
|
||||||
|
$this->source->dataPacket($pk);
|
||||||
|
}
|
||||||
|
|
||||||
public function execute() : bool{
|
public function execute() : bool{
|
||||||
if(parent::execute()){
|
if(parent::execute()){
|
||||||
switch($this->primaryOutput->getId()){
|
switch($this->primaryOutput->getId()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user