Allow armor replacing (changing armor to another armor)

This commit is contained in:
Shoghi Cervantes 2013-08-20 11:23:55 +02:00
parent e42314ade7
commit a34595292d
3 changed files with 10 additions and 3 deletions

View File

@ -415,7 +415,6 @@ class PlayerAPI{
public function remove($CID){ public function remove($CID){
if(isset($this->server->clients[$CID])){ if(isset($this->server->clients[$CID])){
$player = $this->server->clients[$CID]; $player = $this->server->clients[$CID];
$this->server->clients[$CID] = null;
unset($this->server->clients[$CID]); unset($this->server->clients[$CID]);
$player->close(); $player->close();
if($player->username != "" and ($player->data instanceof Config)){ if($player->username != "" and ($player->data instanceof Config)){
@ -423,8 +422,8 @@ class PlayerAPI{
} }
$this->server->query("DELETE FROM players WHERE name = '".$player->username."';"); $this->server->query("DELETE FROM players WHERE name = '".$player->username."';");
if($player->entity instanceof Entity){ if($player->entity instanceof Entity){
$player->entity->player = null; unset($player->entity->player);
$player->entity = null; unset($player->entity);
} }
$this->server->api->entity->remove($player->eid); $this->server->api->entity->remove($player->eid);
$player = null; $player = null;

View File

@ -1432,6 +1432,10 @@ class Player{
}elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){ }elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){
$this->armor[$i] = $this->getSlot($sl); $this->armor[$i] = $this->getSlot($sl);
$this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false); $this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false);
}elseif($s->getID() !== AIR and $slot->getID() !== AIR and ($sl = $this->hasItem($s->getID())) !== false){
$item = $this->armor[$i];
$this->armor[$i] = $this->getSlot($sl);
$this->setSlot($sl, $item, false);
}else{ }else{
$data["slot$i"] = 255; $data["slot$i"] = 255;
} }

View File

@ -383,6 +383,10 @@ class Entity extends Position{
$this->tickCounter = 0; $this->tickCounter = 0;
} }
if($this->closed === true){
return false;
}
if($this->isStatic === false){ if($this->isStatic === false){
$startX = floor($this->x - 0.5 - $this->size - 1); $startX = floor($this->x - 0.5 - $this->size - 1);
$y = (int) round($this->y - 1); $y = (int) round($this->y - 1);