Don't explode when data contains invalid dye colour IDs

This commit is contained in:
Dylan K. Taylor
2021-04-28 13:39:03 +01:00
parent a44203a3d4
commit d5e5a81cff
6 changed files with 27 additions and 11 deletions

View File

@@ -104,7 +104,8 @@ class Banner extends ItemBlockWallOrFloor{
if($patterns !== null){
/** @var CompoundTag $t */
foreach($patterns as $t){
$this->patterns[] = new BannerPatternLayer(BannerPatternType::fromString($t->getString(self::TAG_PATTERN_NAME)), $colorIdMap->fromInvertedId($t->getInt(self::TAG_PATTERN_COLOR)));
$patternColor = $colorIdMap->fromInvertedId($t->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK(); //TODO: missing pattern colour should be an error
$this->patterns[] = new BannerPatternLayer(BannerPatternType::fromString($t->getString(self::TAG_PATTERN_NAME)), $patternColor);
}
}
}