mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Added Block->getVariantBitmask(0 to cut down on getDrops() boilerplate, fixed several blocks incorrectly retaining meta when broken
This commit is contained in:
@ -398,8 +398,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
||||
/** @var int */
|
||||
protected $id;
|
||||
/** @var int */
|
||||
protected $meta = 0;
|
||||
/** @var string */
|
||||
protected $fallbackName;
|
||||
@ -460,6 +461,19 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
$this->meta = $meta & 0x0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitmask to use to remove superfluous information from block meta when getting its item form or name.
|
||||
* This defaults to -1 (don't remove any data). Used to remove rotation data and bitflags from block drops.
|
||||
*
|
||||
* If your block should not have any meta value when it's dropped as an item, override this to return 0 in
|
||||
* descendent classes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getVariantBitmask() : int{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
|
||||
*
|
||||
@ -658,7 +672,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*/
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage(), 1),
|
||||
Item::get($this->getItemId(), $this->getDamage() & $this->getVariantBitmask(), 1),
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user