Skip to content

Commit a5d88ab

Browse files
committed
Fixed biome data loading
1 parent 53fb00a commit a5d88ab

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/network/mcpe/cache/StaticPacketCache.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
3434
use pocketmine\utils\Filesystem;
3535
use pocketmine\utils\SingletonTrait;
36+
use pocketmine\utils\Utils;
3637
use pocketmine\world\biome\model\BiomeDefinitionEntryData;
3738
use function count;
3839
use function get_debug_type;
@@ -54,18 +55,19 @@ private static function loadCompoundFromFile(string $filePath) : CacheableNbt{
5455
* @return list<BiomeDefinitionEntry>
5556
*/
5657
private static function loadBiomeDefinitionModel(string $filePath) : array{
57-
$biomeEntries = json_decode(Filesystem::fileGetContents($filePath), false);
58+
$biomeEntries = json_decode(Filesystem::fileGetContents($filePath), associative: true);
5859
if(!is_array($biomeEntries)){
5960
throw new SavedDataLoadingException("$filePath root should be an array, got " . get_debug_type($biomeEntries));
6061
}
6162

6263
$jsonMapper = new \JsonMapper();
6364
$jsonMapper->bExceptionOnMissingData = true;
6465
$jsonMapper->bStrictObjectTypeChecking = true;
66+
$jsonMapper->bEnforceMapType = false;
6567

6668
$entries = [];
67-
foreach($biomeEntries as $biomeName => $entry){
68-
if(!is_object($entry)){
69+
foreach(Utils::promoteKeys($biomeEntries) as $biomeName => $entry){
70+
if(!is_array($entry)){
6971
throw new SavedDataLoadingException("$filePath should be an array of objects, got " . get_debug_type($entry));
7072
}
7173

@@ -74,7 +76,7 @@ private static function loadBiomeDefinitionModel(string $filePath) : array{
7476

7577
$mapWaterColour = $biomeDefinition->mapWaterColour;
7678
$entries[] = new BiomeDefinitionEntry(
77-
$biomeName,
79+
(string) $biomeName,
7880
$biomeDefinition->id,
7981
$biomeDefinition->temperature,
8082
$biomeDefinition->downfall,

0 commit comments

Comments
 (0)