Many many changes related to inventory transactions, fixed item dropping, fixed creative menu

This commit is contained in:
Dylan K. Taylor
2017-08-11 19:57:30 +01:00
parent c1ff7bbef4
commit 8958b3c51c
14 changed files with 497 additions and 282 deletions

View File

@ -351,6 +351,12 @@ class PlayerInventory extends BaseInventory{
}
public function setItem(int $index, Item $item, bool $send = true) : bool{
if($item->isNull()){
$item = Item::get(Item::AIR, 0, 0);
}else{
$item = clone $item;
}
if($index >= $this->getSize()){ //Armor change
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
if($ev->isCancelled() and $this->getHolder() instanceof Human){
@ -367,9 +373,8 @@ class PlayerInventory extends BaseInventory{
$item = $ev->getNewItem();
}
$old = $this->getItem($index);
$this->slots[$index] = clone $item;
$this->slots[$index] = $item;
$this->onSlotChange($index, $old, $send);
return true;