mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Falling Entities, better Physics [not final]
This commit is contained in:
@@ -25,9 +25,24 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
*/
|
||||
|
||||
class FallableBlock extends GenericBlock{
|
||||
class FallableBlock extends SolidBlock{
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
parent::__construct($id, $meta, $name);
|
||||
$this->hasPhysics = true;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($this->getSide(0)->getID() === AIR){
|
||||
$data = array(
|
||||
"x" => $this->x + 0.5,
|
||||
"y" => $this->y + 0.5,
|
||||
"z" => $this->z + 0.5,
|
||||
"Tile" => $this->id,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($this->level, $e->eid);
|
||||
$this->level->setBlock($this, new AirBlock());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user