Introduce a "block write-batch" concept (#2555)

Make use of writebatch to generate trees, doors and double plants safely

- Fixes #2441 
- Fixes #2548 
- Closes #2498
This commit is contained in:
Dylan T
2018-12-29 12:00:14 +00:00
committed by GitHub
parent aaaddd1fd6
commit ac87319aed
5 changed files with 175 additions and 23 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\BlockDataValidator;
use pocketmine\item\Item;
use pocketmine\level\BlockWriteBatch;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Bearing;
@ -124,9 +125,10 @@ abstract class Door extends Transparent{
$topHalf = clone $this;
$topHalf->top = true;
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
$this->level->setBlock($blockUp, $topHalf); //Top
return true;
$write = new BlockWriteBatch();
$write->addBlock($blockReplace, $this)->addBlock($blockUp, $topHalf);
return $write->apply($this->level);
}
return false;