diff --git a/src/item/ItemFactory.php b/src/item/ItemFactory.php index e06094da1..a03c3caed 100644 --- a/src/item/ItemFactory.php +++ b/src/item/ItemFactory.php @@ -252,8 +252,8 @@ class ItemFactory{ } foreach(Potion::ALL as $type){ - $this->register(new Potion(ItemIds::POTION, $type, "Potion")); - $this->register(new SplashPotion(ItemIds::SPLASH_POTION, $type, "Splash Potion")); + $this->register(new Potion(ItemIds::POTION, $type, "Potion", $type)); + $this->register(new SplashPotion(ItemIds::SPLASH_POTION, $type, "Splash Potion", $type)); } foreach(TreeType::getAll() as $type){ diff --git a/src/item/Potion.php b/src/item/Potion.php index 54806da72..a8e66bc1f 100644 --- a/src/item/Potion.php +++ b/src/item/Potion.php @@ -253,6 +253,14 @@ class Potion extends Item implements Consumable{ return []; } + /** @var int */ + private $potionId; + + public function __construct(int $id, int $variant, string $name, int $potionId){ + parent::__construct($id, $variant, $name); + $this->potionId = $potionId; + } + public function getMaxStackSize() : int{ return 1; } @@ -263,7 +271,7 @@ class Potion extends Item implements Consumable{ public function getAdditionalEffects() : array{ //TODO: check CustomPotionEffects NBT - return self::getPotionEffectsById($this->meta); + return self::getPotionEffectsById($this->potionId); } public function getResidue(){ diff --git a/src/item/SplashPotion.php b/src/item/SplashPotion.php index 445590e28..20c09aa4e 100644 --- a/src/item/SplashPotion.php +++ b/src/item/SplashPotion.php @@ -30,13 +30,21 @@ use pocketmine\player\Player; class SplashPotion extends ProjectileItem{ + /** @var int */ + private $potionId; + + public function __construct(int $id, int $variant, string $name, int $potionId){ + parent::__construct($id, $variant, $name); + $this->potionId = $potionId; + } + public function getMaxStackSize() : int{ return 1; } protected function createEntity(Location $location, Player $thrower) : Throwable{ $projectile = new SplashPotionEntity($location, $thrower); - $projectile->setPotionId($this->meta); + $projectile->setPotionId($this->potionId); return $projectile; }