Fixed item spawning

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-05 15:01:21 +01:00
parent 344449fa12
commit c2a45212dd
2 changed files with 12 additions and 7 deletions

View File

@ -57,16 +57,16 @@ class BlockAPI{
if(!isset($b[1])){
$meta = 0;
}else{
$meta = ((int) $b[1]) & 0x0F;
$meta = (int) $b[1];
}
$block = ((int) $b[0]) & 0xFF;
$block = ((int) $b[0]) & 0xFFFF;
if(!isset($params[2])){
$amount = 64;
}else{
$amount = $params[2] & 0xFF;
$amount = (int) $params[2];
}
if(isset($params[3])){
$meta = $params[3] & 0x0F;
$meta = (int) $params[3];
}
if(($player = $this->server->api->player->get($username)) !== false){
$this->drop($player->entity->x, $player->entity->y, $player->entity->z, $block, $meta, $amount);
@ -202,10 +202,14 @@ class BlockAPI{
"stack" => $stack,
);
$data["x"] += mt_rand(2, 8) / 10;
$data["y"] += mt_rand(2, 8) / 10;
$data["y"] += 0.19;
$data["z"] += mt_rand(2, 8) / 10;
$e = $this->server->api->entity->add(ENTITY_ITEM, $block, $data);
$this->server->api->entity->spawnToAll($e->eid);
for($count = $stack; $count > 0; ){
$data["stack"] = min(64, $count);
$count -= $data["stack"];
$e = $this->server->api->entity->add(ENTITY_ITEM, $block, $data);
$this->server->api->entity->spawnToAll($e->eid);
}
}
public function blockAction($data, $event){

View File

@ -77,6 +77,7 @@ class Entity extends stdClass{
public function update(){
if($this->class === ENTITY_ITEM){
$this->server->api->dhandle("entity.move", $this->eid);
$player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true);
if($player !== true and $player !== false){
if($this->server->api->dhandle("player.item.pick", array(