Skip to content

Commit 3e0d9ef

Browse files
committed
CompoundTag: quietly ignore repeated keys, instead of throwing
this isn't ideal, but we don't have much of a choice; many chunks in very old PM worlds are affected by the furnace bug (basically any chunk with a furnace); we have no other way to avoid losing the entire chunk to corruption errors
1 parent f6de897 commit 3e0d9ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/tag/CompoundTag.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
namespace pocketmine\nbt\tag;
2525

2626
use pocketmine\nbt\NBT;
27-
use pocketmine\nbt\NbtDataException;
2827
use pocketmine\nbt\NbtStreamReader;
2928
use pocketmine\nbt\NbtStreamWriter;
3029
use pocketmine\nbt\NoSuchTagException;
@@ -292,7 +291,12 @@ public static function read(NbtStreamReader $reader, ReaderTracker $tracker) : s
292291
$name = $reader->readString();
293292
$tag = NBT::createTag($type, $reader, $tracker);
294293
if($result->getTag($name) !== null){
295-
throw new NbtDataException("Duplicate key \"$name\"");
294+
//this is technically a corruption case, but it's very common on older PM worlds (pretty much every
295+
//furnace in PM worlds prior to 2017 is affected), and since we can't extricate this borked data
296+
//from the rest in Anvil/McRegion worlds, we can't barf on this - it would result in complete loss
297+
//of the chunk.
298+
//TODO: add a flag to enable throwing on this (strict mode)
299+
continue;
296300
}
297301
$result->setTag($name, $tag);
298302
}

0 commit comments

Comments
 (0)