From 742fbc25c3104ca1f4855b030339accbeb911c6a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 20 Oct 2018 21:42:34 +0100 Subject: [PATCH] BlockFactory: fixed 0 being assumed to be default if used this defeated the whole point of adding this code ... --- src/pocketmine/block/BlockFactory.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 9fd5c8625..c793caae6 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -467,9 +467,8 @@ class BlockFactory{ if(!$override and self::isRegistered($id, $variant)){ throw new \InvalidArgumentException("Block registration conflicts with an existing block"); } - self::fillStaticArrays(($id << 4) | $variant, $block); //register default state mapped to variant, for blocks which don't use 0 as valid state - for($m = $variant + 1; $m <= ($variant | $stateMask); ++$m){ + for($m = $variant; $m <= ($variant | $stateMask); ++$m){ if(($m & ~$stateMask) !== $variant){ continue; } @@ -486,6 +485,10 @@ class BlockFactory{ self::fillStaticArrays($index, $v); } } + + if(!self::isRegistered($id, $variant)){ + self::fillStaticArrays(($id << 4) | $variant, $block); //register default state mapped to variant, for blocks which don't use 0 as valid state + } } private static function fillStaticArrays(int $index, Block $block) : void{