From 6553c82320e30b4377eedf3625bc77101d93eb7b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 30 Jun 2017 16:38:16 +0100 Subject: [PATCH] Fix random block ticking losing randomness on third iteration More expensive to do it this way, but this should be foolproof. The old method ran short by 4 or 5 bits, causing the Y coordinate of the third loop to be always < 8 and the Z coordinate to always be 0. --- src/pocketmine/level/Level.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 0d80423c62..fc964d9c12 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -968,11 +968,11 @@ class Level implements ChunkManager, Metadatable{ foreach($chunk->getSubChunks() as $Y => $subChunk){ if(!$subChunk->isEmpty()){ - $k = mt_rand(0, 0x7fffffff); - for($i = 0; $i < 3; ++$i, $k >>= 10){ + for($i = 0; $i < 3; ++$i){ + $k = mt_rand(0, 0xfff); $x = $k & 0x0f; - $y = ($k >> 8) & 0x0f; - $z = ($k >> 16) & 0x0f; + $y = ($k >> 4) & 0x0f; + $z = ($k >> 8) & 0x0f; $blockId = $subChunk->getBlockId($x, $y, $z); if(isset($this->randomTickBlocks[$blockId])){