mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
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:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\Color;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\PillarRotationTrait;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\item\Item;
|
||||
@ -470,10 +471,16 @@ class BlockFactory{
|
||||
$index = ($id << 4) | $m;
|
||||
|
||||
$v = clone $block;
|
||||
$v->readStateFromMeta($m & $stateMask);
|
||||
if($v->getDamage() === $m){ //don't register anything that isn't the same when we read it back again
|
||||
self::fillStaticArrays($index, $v);
|
||||
try{
|
||||
$v->readStateFromMeta($m & $stateMask);
|
||||
if($v->getDamage() !== $m){
|
||||
throw new InvalidBlockStateException("Corrupted meta"); //don't register anything that isn't the same when we read it back again
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination
|
||||
continue;
|
||||
}
|
||||
|
||||
self::fillStaticArrays($index, $v);
|
||||
}
|
||||
|
||||
if(!self::isRegistered($id, $variant)){
|
||||
|
Reference in New Issue
Block a user