Item pickup

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-05 03:16:11 +01:00
parent 57282225d2
commit 518afeae48
2 changed files with 39 additions and 27 deletions

View File

@ -81,6 +81,8 @@ class Entity extends stdClass{
if($player !== true and $player !== false){ if($player !== true and $player !== false){
if($this->server->api->dhandle("player.item.pick", array( if($this->server->api->dhandle("player.item.pick", array(
"eid" => $player["EID"], "eid" => $player["EID"],
"block" => $this->type,
"meta" => $this->meta,
"target" => $this->eid "target" => $this->eid
)) !== false){ )) !== false){
$this->close(); $this->close();
@ -163,6 +165,7 @@ class Entity extends stdClass{
$this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";"); $this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";");
$this->server->api->dhandle("entity.remove", $this->eid); $this->server->api->dhandle("entity.remove", $this->eid);
$this->closed = true; $this->closed = true;
unset($this);
} }
} }

View File

@ -114,6 +114,9 @@ class Player{
public function eventHandler($data, $event){ public function eventHandler($data, $event){
switch($event){ switch($event){
case "player.item.pick": case "player.item.pick":
if($data["eid"] === $this->eid){
$data["eid"] = 0;
}
$this->dataPacket(MC_TAKE_ITEM_ENTITY, $data); $this->dataPacket(MC_TAKE_ITEM_ENTITY, $data);
break; break;
case "player.equipment.change": case "player.equipment.change":
@ -278,6 +281,8 @@ class Player{
)); ));
break; break;
case MC_READY: case MC_READY:
switch($data["status"]){
case 1:
if($this->spawned !== false){ if($this->spawned !== false){
break; break;
} }
@ -304,6 +309,10 @@ class Player{
$this->eventHandler("Your connection is bad, you may experience lag and slow map loading.", "server.chat"); $this->eventHandler("Your connection is bad, you may experience lag and slow map loading.", "server.chat");
} }
break; break;
case 2://Chunk loaded?
break;
}
break;
case MC_MOVE_PLAYER: case MC_MOVE_PLAYER:
if(is_object($this->entity)){ if(is_object($this->entity)){
$this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]); $this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]);
@ -334,7 +343,7 @@ class Player{
break; break;
case MC_USE_ITEM: case MC_USE_ITEM:
$data["eid"] = $this->eid; $data["eid"] = $this->eid;
if(Utils::distance($this->entity->position, $data) > 8){ if(Utils::distance($this->entity->position, $data) > 10){
break; break;
} }
$this->server->handle("player.block.action", $data); $this->server->handle("player.block.action", $data);