Fixed touching items with an empty hand

This commit is contained in:
Shoghi Cervantes 2014-05-28 15:22:25 +02:00
parent 70e340086d
commit c778e0467e
2 changed files with 4 additions and 4 deletions

View File

@ -1529,7 +1529,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
break; break;
} }
if($packet->slot === 0x28 or $packet->slot === 0){ //0 for 0.8.0 compatibility if($packet->slot === 0x28 or $packet->slot === 0 or $packet->slot === 255){ //0 for 0.8.0 compatibility
$packet->slot = -1; //Air $packet->slot = -1; //Air
}else{ }else{
$packet->slot -= 9; //Get real block slot $packet->slot -= 9; //Get real block slot

View File

@ -34,7 +34,7 @@ use pocketmine\Server;
class PlayerInventory extends BaseInventory{ class PlayerInventory extends BaseInventory{
protected $itemInHandIndex = 0; protected $itemInHandIndex = -1;
/** @var int[] */ /** @var int[] */
protected $hotbar; protected $hotbar;
@ -101,10 +101,10 @@ class PlayerInventory extends BaseInventory{
} }
public function setHeldItemSlot($slot){ public function setHeldItemSlot($slot){
if($slot >= 0 and $slot < $this->getSize()){ if($slot >= -1 and $slot < $this->getSize()){
$item = $this->getItem($slot); $item = $this->getItem($slot);
if($this->getHolder() instanceof Player){ if($this->getHolder() instanceof Player){
Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, 0)); Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $this->itemInHandIndex));
if($ev->isCancelled()){ if($ev->isCancelled()){
$this->sendHeldItem($this->getHolder()); $this->sendHeldItem($this->getHolder());