Falling Entities, better Physics [not final]

This commit is contained in:
Shoghi Cervantes
2013-05-28 22:03:58 +02:00
parent cb03daf28a
commit 58fd67d2ed
8 changed files with 125 additions and 32 deletions

View File

@@ -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());
}
}
}