From 9a8902d1fe26d492346c9e9a50ab99dd28e5d5fd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 19 Jul 2022 16:08:05 +0100 Subject: [PATCH] LegacyToStringMap: don't throw if the existing mapping is the same as the one we want to register this was making it inconvenient for plugins to use BlockIdMetaUpgrader->addMapping(), because the block legacy ID map contains IDs up to 1.16, but the table of mapped 1.12 blockstates only goes up to ... well ... 1.12. This left a gap of several versions' blocks unable to be mapped. --- src/data/bedrock/LegacyToStringIdMap.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/data/bedrock/LegacyToStringIdMap.php b/src/data/bedrock/LegacyToStringIdMap.php index d808b35df..e5181e193 100644 --- a/src/data/bedrock/LegacyToStringIdMap.php +++ b/src/data/bedrock/LegacyToStringIdMap.php @@ -66,6 +66,9 @@ abstract class LegacyToStringIdMap{ public function add(string $string, int $legacy) : void{ if(isset($this->legacyToString[$legacy])){ + if($this->legacyToString[$legacy] === $string){ + return; + } throw new \InvalidArgumentException("Legacy ID $legacy is already mapped to string " . $this->legacyToString[$legacy]); } $this->legacyToString[$legacy] = $string;