From 3d038b28ffe6d0635eefc6816afbadecfa6b51e8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 24 Dec 2022 15:19:56 +0000 Subject: [PATCH] SplashPotion: const-ify missed NBT key --- src/entity/EntityFactory.php | 2 +- src/entity/projectile/SplashPotion.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index e69cfd643..8aa83b471 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -154,7 +154,7 @@ final class EntityFactory{ }, ['Snowball', 'minecraft:snowball'], LegacyIds::SNOWBALL); $this->register(SplashPotion::class, function(World $world, CompoundTag $nbt) : SplashPotion{ - $potionType = PotionTypeIdMap::getInstance()->fromId($nbt->getShort("PotionId", PotionTypeIds::WATER)); + $potionType = PotionTypeIdMap::getInstance()->fromId($nbt->getShort(SplashPotion::TAG_POTION_ID, PotionTypeIds::WATER)); if($potionType === null){ throw new SavedDataLoadingException("No such potion type"); } diff --git a/src/entity/projectile/SplashPotion.php b/src/entity/projectile/SplashPotion.php index a942d9622..05f64e525 100644 --- a/src/entity/projectile/SplashPotion.php +++ b/src/entity/projectile/SplashPotion.php @@ -50,6 +50,8 @@ use function sqrt; class SplashPotion extends Throwable{ + public const TAG_POTION_ID = "PotionId"; //TAG_Short + public static function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; } protected $gravity = 0.05; @@ -66,7 +68,7 @@ class SplashPotion extends Throwable{ public function saveNBT() : CompoundTag{ $nbt = parent::saveNBT(); - $nbt->setShort("PotionId", PotionTypeIdMap::getInstance()->toId($this->getPotionType())); + $nbt->setShort(self::TAG_POTION_ID, PotionTypeIdMap::getInstance()->toId($this->getPotionType())); return $nbt; }