mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 03:17:12 +00:00
Handle a hotbar queue to allow using more than the first slot (won't save order due to the protocol)
This commit is contained in:
parent
7506f01302
commit
bb82e7be50
@ -103,17 +103,26 @@ class PlayerInventory extends BaseInventory{
|
||||
public function setHeldItemSlot($slot){
|
||||
if($slot >= -1 and $slot < $this->getSize()){
|
||||
$item = $this->getItem($slot);
|
||||
|
||||
$itemIndex = $this->getHeldItemIndex();
|
||||
|
||||
for($i = 0; $i < $this->getHotbarSize(); ++$i){
|
||||
if($this->getHotbarSlotIndex($i) === $slot){
|
||||
$itemIndex = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getHolder() instanceof Player){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $this->itemInHandIndex));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $itemIndex));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendHeldItem($this->getHolder());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setHotbarSlotIndex($this->itemInHandIndex, $slot);
|
||||
$this->sendHeldItem($this->getHolder()->getViewers());
|
||||
$this->setHotbarSlotIndex($itemIndex, $slot);
|
||||
$this->setHeldItemIndex($itemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user