Tighten validity checks for block metadata

This filters out over 200 invalid states which were previously considered just fine, including zero-width cakes, buttons with broken facing values, furnace/chest with crazy values, and more.
This commit is contained in:
Dylan K. Taylor
2018-12-28 14:33:09 +00:00
parent 333773bf14
commit 78a80a6958
43 changed files with 222 additions and 59 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\BlockDataValidator;
use pocketmine\entity\Entity;
use pocketmine\event\block\BlockFormEvent;
use pocketmine\event\block\BlockSpreadEvent;
@ -69,7 +70,7 @@ abstract class Liquid extends Transparent{
}
public function readStateFromMeta(int $meta) : void{
$this->decay = $meta & 0x07;
$this->decay = BlockDataValidator::readBoundedInt("decay", $meta & 0x07, 0, 7);
$this->falling = ($meta & 0x08) !== 0;
}