mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Fixed desynchronization of hunger when cancelling food-related events (#4691)
This commit is contained in:
parent
f62cfe8ae3
commit
bcc0f1e733
@ -27,6 +27,7 @@ use pocketmine\block\BaseSign;
|
|||||||
use pocketmine\block\ItemFrame;
|
use pocketmine\block\ItemFrame;
|
||||||
use pocketmine\block\utils\SignText;
|
use pocketmine\block\utils\SignText;
|
||||||
use pocketmine\entity\animation\ConsumingItemAnimation;
|
use pocketmine\entity\animation\ConsumingItemAnimation;
|
||||||
|
use pocketmine\entity\Attribute;
|
||||||
use pocketmine\entity\InvalidSkinException;
|
use pocketmine\entity\InvalidSkinException;
|
||||||
use pocketmine\event\player\PlayerEditBookEvent;
|
use pocketmine\event\player\PlayerEditBookEvent;
|
||||||
use pocketmine\inventory\transaction\action\InventoryAction;
|
use pocketmine\inventory\transaction\action\InventoryAction;
|
||||||
@ -371,6 +372,8 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
case UseItemTransactionData::ACTION_CLICK_AIR:
|
case UseItemTransactionData::ACTION_CLICK_AIR:
|
||||||
if($this->player->isUsingItem()){
|
if($this->player->isUsingItem()){
|
||||||
if(!$this->player->consumeHeldItem()){
|
if(!$this->player->consumeHeldItem()){
|
||||||
|
$hungerAttr = $this->player->getAttributeMap()->get(Attribute::HUNGER) ?? throw new AssumptionFailedError();
|
||||||
|
$hungerAttr->markSynchronized(false);
|
||||||
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
|
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user