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