From 7399e9036af7cdcbbb346ea50bcb599640e76a67 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 25 Nov 2018 14:53:57 +0000 Subject: [PATCH] Block: add method isSameState() to allow black-box comparison of blockstates --- src/pocketmine/block/Block.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 17bdaaa615..0c1fd4d43b 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -193,6 +193,17 @@ class Block extends Position implements BlockIds, Metadatable{ return $this->getId() === $other->getId() and $this->getVariant() === $other->getVariant(); } + /** + * Returns whether the given block has the same type and properties as this block. + * + * @param Block $other + * + * @return bool + */ + public function isSameState(Block $other) : bool{ + return $this->isSameType($other) and $this->writeStateToMeta() === $other->writeStateToMeta(); + } + /** * AKA: Block->isPlaceable * @return bool