mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 15:36:08 +00:00
Make potion types dynamic
It became obvious this was needed when I wanted to make new IDs for existing items - there's no way I'm unrolling those registrations...
This commit is contained in:
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\data\bedrock\PotionTypeIdMap;
|
||||
use pocketmine\entity\Location;
|
||||
use pocketmine\entity\projectile\SplashPotion as SplashPotionEntity;
|
||||
use pocketmine\entity\projectile\Throwable;
|
||||
@@ -32,13 +33,25 @@ class SplashPotion extends ProjectileItem{
|
||||
|
||||
private PotionType $potionType;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, PotionType $potionType){
|
||||
public function __construct(ItemIdentifier $identifier, string $name){
|
||||
$this->potionType = PotionType::WATER();
|
||||
parent::__construct($identifier, $name);
|
||||
$this->potionType = $potionType;
|
||||
}
|
||||
|
||||
public function getMeta() : int{
|
||||
return PotionTypeIdMap::getInstance()->toId($this->potionType);
|
||||
}
|
||||
|
||||
public function getType() : PotionType{ return $this->potionType; }
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PotionType $type) : self{
|
||||
$this->potionType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user