Block: Cleaned up double-block break handling, close #1862, close #1525

This now removes the need for recursing around for structures comprised of multiple blocks. Instead, override getAffectedBlocks() to return all blocks that need to be deleted when the current block is deleted, and make sure that only one half of the block drops something. When a player breaks one of the blocks, all the blocks affected by that block will also be destroyed, creating particles and sounds where appropriate.

This fixes creative drops for double plants and beds.
This commit is contained in:
Dylan K. Taylor
2018-01-03 13:00:57 +00:00
parent 1bdb68b7da
commit 3a0cbd1cd4
6 changed files with 81 additions and 54 deletions

View File

@ -513,6 +513,16 @@ class Block extends Position implements BlockIds, Metadatable{
);
}
/**
* Returns a list of blocks that this block is part of. In most cases, only contains the block itself, but in cases
* such as double plants, beds and doors, will contain both halves.
*
* @return Block[]
*/
public function getAffectedBlocks() : array{
return [$this];
}
/**
* @return string
*/