Added block cloning fix

This commit is contained in:
Shoghi Cervantes
2013-06-01 19:58:54 +02:00
parent 24ba7cbbd1
commit 54b73e5f82
7 changed files with 41 additions and 52 deletions

View File

@@ -33,24 +33,7 @@ class FallableBlock extends SolidBlock{
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);
ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL);
return $ret;
}
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();
$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

@@ -39,14 +39,30 @@ class GenericBlock extends Block{
}
public function onBreak(Item $item, Player $player){
return $this->level->setBlock($this, new AirBlock());
return $this->level->setBlock($this, new AirBlock(), true, false, true);
}
public function onUpdate($type){
if($this->hasPhysics === true){
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();
$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);
$server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
}
return false;
}
return false;
}
public function onActivate(Item $item, Player $player){
return ($this->isActivable);
return $this->isActivable;
}
}