mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
Fixed item spawning
This commit is contained in:
parent
344449fa12
commit
c2a45212dd
@ -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){
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user