mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Redesign inventory listening API
given that inventory listeners are no longer allowed to fiddle with the outcome of changing contents, it's now possible to allow having multiple listeners receiving events. It's likely that this will be used for network inventory sync in the near future.
This commit is contained in:
@ -618,8 +618,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
|
||||
$inventoryTag = $nbt->getListTag("Inventory");
|
||||
if($inventoryTag !== null){
|
||||
$armorListener = $this->armorInventory->getSlotChangeListener();
|
||||
$this->armorInventory->setSlotChangeListener(null);
|
||||
$armorListeners = $this->armorInventory->getChangeListeners();
|
||||
$this->armorInventory->removeChangeListeners(...$armorListeners);
|
||||
|
||||
/** @var CompoundTag $item */
|
||||
foreach($inventoryTag as $i => $item){
|
||||
@ -633,7 +633,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
$this->armorInventory->setSlotChangeListener($armorListener);
|
||||
$this->armorInventory->addChangeListeners(...$armorListeners);
|
||||
}
|
||||
|
||||
$enderChestInventoryTag = $nbt->getListTag("EnderChestInventory");
|
||||
|
Reference in New Issue
Block a user