mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +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){
|
public function setHeldItemSlot($slot){
|
||||||
if($slot >= -1 and $slot < $this->getSize()){
|
if($slot >= -1 and $slot < $this->getSize()){
|
||||||
$item = $this->getItem($slot);
|
$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){
|
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()){
|
if($ev->isCancelled()){
|
||||||
$this->sendHeldItem($this->getHolder());
|
$this->sendHeldItem($this->getHolder());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setHotbarSlotIndex($this->itemInHandIndex, $slot);
|
$this->setHotbarSlotIndex($itemIndex, $slot);
|
||||||
$this->sendHeldItem($this->getHolder()->getViewers());
|
$this->setHeldItemIndex($itemIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user