mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Added block cloning fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user