New direct block method, better block placement sending

This commit is contained in:
Shoghi Cervantes
2013-06-01 00:32:23 +02:00
parent 722eb6d1f9
commit 24ba7cbbd1
7 changed files with 72 additions and 46 deletions

View File

@@ -31,6 +31,12 @@ class FallableBlock extends SolidBlock{
$this->hasPhysics = true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->blockUpdate($this, BLOCK_UPDATE_NORMAL);
return $ret;
}
public function onUpdate($type){
if($this->getSide(0)->getID() === AIR){
$data = array(
@@ -40,9 +46,11 @@ class FallableBlock extends SolidBlock{
"Tile" => $this->id,
);
$server = ServerAPI::request();
$this->level->setBlock($this, new AirBlock());
$this->level->setBlock($this, new AirBlock(), false, false, true);
$e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
$server->api->entity->spawnToAll($this->level, $e->eid);
return BLOCK_UPDATE_NORMAL;
}
return false;
}
}

View File

@@ -31,7 +31,7 @@ class GenericBlock extends Block{
parent::__construct($id, $meta, $name);
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
return $this->level->setBlock($block, $this);
return $this->level->setBlock($this, $this, true, false, true);
}
public function isBreakable(Item $item, Player $player){