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:
Dylan K. Taylor
2022-06-28 23:33:25 +01:00
parent c0e178c19c
commit 6058032807
7 changed files with 128 additions and 454 deletions

View File

@@ -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;
}