This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-29 20:53:43 +01:00
parent 2011d1d339
commit 71b12191b2
4 changed files with 42 additions and 1 deletions

View file

@ -583,6 +583,30 @@ class Player{
}
//$this->entity->setHealth($data["health"], "client");
break;
case MC_ENTITY_EVENT:
$data["eid"] = $this->eid;
switch($data["event"]){
case 9: //Eating
$items = array(
260 => 2, //Apples
282 => 10, //Stew
297 => 5, //Bread
319 => 3,
320 => 8,
363 => 3,
364 => 8,
);
if(isset($items[$this->equipment[0]])){
$this->removeItem($this->equipment[0], 0, 1);
$this->dataPacket(MC_ENTITY_EVENT, array(
"eid" => 0,
"event" => 9,
));
$this->entity->heal($items[$this->equipment[0]], "eating");
}
break;
}
break;
case MC_DROP_ITEM:
if($this->server->handle("player.drop", $data) !== false){
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);

View file

@ -478,6 +478,9 @@ class CustomPacketHandler{
$this->raw .= Utils::writeInt($this->data["target"]);*/
}
break;
case MC_PLAYER_ACTION:
//TODO
break;
case MC_SET_ENTITY_DATA:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));

View file

@ -162,7 +162,7 @@ class Entity extends stdClass{
}
if($this->y < -16){
$this->harm(8, "void", true); //4 per second
$this->harm(8, "void", true);
}
if($this->fire > 0){
@ -470,6 +470,10 @@ class Entity extends stdClass{
return $this->setHealth($this->getHealth() - ((int) $dmg), $cause, $force);
}
public function heal($health, $cause = "generic"){
return $this->setHealth(min(20, $this->getHealth() + ((int) $health)), $cause);
}
public function setHealth($health, $cause = "generic", $force = false){
$health = (int) $health;
$harm = false;