Properly close inventory windows from Players

This commit is contained in:
Shoghi Cervantes 2014-11-27 13:32:07 +01:00
parent 441a98e60a
commit a3e50f6337
4 changed files with 8 additions and 6 deletions

View File

@ -1150,7 +1150,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk = new MovePlayerPacket(); $pk = new MovePlayerPacket();
$pk->eid = 0; $pk->eid = 0;
$pk->x = $from->x; $pk->x = $from->x;
$pk->y = $from->y + $this->getEyeHeight() + 0.01; $pk->y = $from->y + $this->getEyeHeight();
$pk->z = $from->z; $pk->z = $from->z;
$pk->bodyYaw = $from->yaw; $pk->bodyYaw = $from->yaw;
$pk->pitch = $from->pitch; $pk->pitch = $from->pitch;

View File

@ -218,7 +218,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$this->getInventory()->close($player); $this->getInventory()->close($player);
} }
} }
$this->inventory = null; foreach($this->inventory->getViewers() as $viewer){
$viewer->removeWindow($this->inventory);
}
parent::close(); parent::close();
} }
} }

View File

@ -59,11 +59,11 @@ class Chest extends Spawnable implements InventoryHolder, Container{
public function close(){ public function close(){
if($this->closed === false){ if($this->closed === false){
foreach($this->getInventory()->getViewers() as $player){ foreach($this->getInventory()->getViewers() as $player){
$this->getInventory()->close($player); $player->removeWindow($this->getInventory());
} }
foreach($this->getRealInventory()->getViewers() as $player){ foreach($this->getInventory()->getViewers() as $player){
$this->getRealInventory()->close($player); $player->removeWindow($this->getRealInventory());
} }
parent::close(); parent::close();
} }

View File

@ -71,7 +71,7 @@ class Furnace extends Tile implements InventoryHolder, Container{
public function close(){ public function close(){
if($this->closed === false){ if($this->closed === false){
foreach($this->getInventory()->getViewers() as $player){ foreach($this->getInventory()->getViewers() as $player){
$this->getInventory()->close($player); $player->removeWindow($this->getInventory());
} }
parent::close(); parent::close();
} }