mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +00:00
Inventory: Fix hotbar spaz
This commit is contained in:
parent
df4c3ec4a6
commit
765bd5ced7
@ -1927,7 +1927,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
$this->inventory->setHeldItemIndex($packet->selectedSlot, false);
|
||||||
$this->inventory->setHeldItemSlot($packet->slot);
|
$this->inventory->setHeldItemSlot($packet->slot);
|
||||||
}else{
|
}else{
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
@ -1938,12 +1938,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
break;
|
break;
|
||||||
}elseif($this->isCreative()){
|
}elseif($this->isCreative()){
|
||||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
$this->inventory->setHeldItemIndex($packet->selectedSlot, false);
|
||||||
$this->inventory->setItem($packet->selectedSlot, $item);
|
$this->inventory->setItem($packet->selectedSlot, $item);
|
||||||
$this->inventory->setHeldItemSlot($packet->selectedSlot);
|
$this->inventory->setHeldItemSlot($packet->selectedSlot);
|
||||||
}else{
|
}else{
|
||||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
$this->inventory->setHeldItemIndex($packet->selectedSlot, false);
|
||||||
$this->inventory->setHeldItemSlot($slot);
|
$this->inventory->setHeldItemSlot($slot);
|
||||||
}else{
|
}else{
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
@ -1951,8 +1951,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
|
||||||
|
|
||||||
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
|
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::USE_ITEM_PACKET:
|
case ProtocolInfo::USE_ITEM_PACKET:
|
||||||
|
@ -68,11 +68,11 @@ class PlayerInventory extends BaseInventory{
|
|||||||
return $this->itemInHandIndex;
|
return $this->itemInHandIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHeldItemIndex($index){
|
public function setHeldItemIndex($index, $send = true){
|
||||||
if($index >= 0 and $index < $this->getHotbarSize()){
|
if($index >= 0 and $index < $this->getHotbarSize()){
|
||||||
$this->itemInHandIndex = $index;
|
$this->itemInHandIndex = $index;
|
||||||
|
|
||||||
if($this->getHolder() instanceof Player){
|
if($this->getHolder() instanceof Player and $send){
|
||||||
$this->sendHeldItem($this->getHolder());
|
$this->sendHeldItem($this->getHolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user