Improved inventory sending, send single slots instead of full inventory as much as possible

This commit is contained in:
Shoghi Cervantes
2014-11-03 11:48:10 +01:00
parent 29d1fd1fc8
commit 86afecec89
2 changed files with 71 additions and 19 deletions

View File

@ -133,8 +133,7 @@ abstract class BaseInventory implements Inventory{
if($holder instanceof Entity){
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $this->getItem($index), $item, $index));
if($ev->isCancelled()){
$this->sendContents($this->getViewers());
$this->sendSlot($index, $this->getViewers());
return false;
}
$item = $ev->getNewItem();
@ -300,8 +299,7 @@ abstract class BaseInventory implements Inventory{
if($holder instanceof Entity){
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $old, $item, $index));
if($ev->isCancelled()){
$this->sendContents($this->getViewers());
$this->sendSlot($index, $this->getViewers());
return false;
}
$item = $ev->getNewItem();