From fe4b5498e6deacc0d22d4137fd7a54f857fc12f1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Jan 2018 11:02:43 +0000 Subject: [PATCH] Level: Fixed 2D block cache not getting counted correctly Fixes #1903 Closes #1906, which, while a pretty solution, is very inefficient (see PR discussion). This is an optimization of microscopic proportions, but the point still stands. --- src/pocketmine/level/Level.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 86cb5c718..35fdc339e 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -932,8 +932,13 @@ class Level implements ChunkManager, Metadatable{ $this->chunkCache = []; $this->blockCache = []; }else{ - if(count($this->blockCache) > 2048){ - $this->blockCache = []; + $count = 0; + foreach($this->blockCache as $list){ + $count += count($list); + if($count > 2048){ + $this->blockCache = []; + break; + } } } }