Possible fix for armor crash

This commit is contained in:
Shoghi Cervantes 2013-07-04 23:33:56 +02:00
parent b776d9d5fc
commit 7efed17b74
2 changed files with 4 additions and 4 deletions

View File

@ -413,7 +413,7 @@ class PlayerAPI{
"z" => $this->server->spawn->z, "z" => $this->server->spawn->z,
), ),
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, array(AIR, 0, 0)), "inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, array(AIR, 0, 0)),
"armor" => array_fill(0, 4, array(AIR, 0, 0)), "armor" => array_fill(0, 4, array(AIR, 0)),
"gamemode" => $this->server->gamemode, "gamemode" => $this->server->gamemode,
"health" => 20, "health" => 20,
"lastIP" => "", "lastIP" => "",

View File

@ -1097,7 +1097,7 @@ class Player{
$this->armor = array(); $this->armor = array();
foreach($this->data->get("armor") as $slot => $item){ foreach($this->data->get("armor") as $slot => $item){
$this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], 1); $this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], $item[0] === 0 ? 0:1);
} }
$this->data->set("lastIP", $this->ip); $this->data->set("lastIP", $this->ip);
@ -1365,7 +1365,7 @@ class Player{
$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);
}else{ }else{
$data["slot$i"] = 0; $data["slot$i"] = 255;
} }
} }
@ -1708,7 +1708,7 @@ class Player{
$data["slot$i"] = $this->armor[$i]->getID() !== AIR ? $this->armor[$i]->getID() - 256:0; $data["slot$i"] = $this->armor[$i]->getID() !== AIR ? $this->armor[$i]->getID() - 256:0;
}else{ }else{
$this->armor[$i] = BlockAPI::getItem(AIR, 0, 0); $this->armor[$i] = BlockAPI::getItem(AIR, 0, 0);
$data["slot$i"] = 0; $data["slot$i"] = 255;
} }
$armor[] = $this->armor[$i]; $armor[] = $this->armor[$i];
} }