Register missing potion types

This commit is contained in:
Dylan K. Taylor 2021-06-19 21:53:08 +01:00
parent 5387456e44
commit 5d6146a01f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 31 additions and 1 deletions

View File

@ -79,6 +79,11 @@ final class PotionTypeIdMap{
$this->register(PotionTypeIds::WEAKNESS, PotionType::WEAKNESS());
$this->register(PotionTypeIds::LONG_WEAKNESS, PotionType::LONG_WEAKNESS());
$this->register(PotionTypeIds::WITHER, PotionType::WITHER());
$this->register(PotionTypeIds::TURTLE_MASTER, PotionType::TURTLE_MASTER());
$this->register(PotionTypeIds::LONG_TURTLE_MASTER, PotionType::LONG_TURTLE_MASTER());
$this->register(PotionTypeIds::STRONG_TURTLE_MASTER, PotionType::STRONG_TURTLE_MASTER());
$this->register(PotionTypeIds::SLOW_FALLING, PotionType::SLOW_FALLING());
$this->register(PotionTypeIds::LONG_SLOW_FALLING, PotionType::LONG_SLOW_FALLING());
}
private function register(int $id, PotionType $type) : void{

View File

@ -61,4 +61,9 @@ final class PotionTypeIds{
public const WEAKNESS = 34;
public const LONG_WEAKNESS = 35;
public const WITHER = 36;
public const TURTLE_MASTER = 37;
public const LONG_TURTLE_MASTER = 38;
public const STRONG_TURTLE_MASTER = 39;
public const SLOW_FALLING = 40;
public const LONG_SLOW_FALLING = 41;
}

View File

@ -152,7 +152,7 @@ final class EntityFactory{
$this->register(SplashPotion::class, function(World $world, CompoundTag $nbt) : SplashPotion{
$potionType = PotionTypeIdMap::getInstance()->fromId($nbt->getShort("PotionId", PotionTypeIds::WATER));
if($potionType === null){
$potionType = PotionType::WATER(); //TODO: this should be an error, but we haven't registered all the types yet
throw new \UnexpectedValueException("No such potion type");
}
return new SplashPotion(EntityDataHelper::parseLocation($nbt, $world), null, $potionType, $nbt);
}, ['ThrownPotion', 'minecraft:potion', 'thrownpotion'], EntityLegacyIds::SPLASH_POTION);

View File

@ -46,8 +46,10 @@ use pocketmine\utils\EnumTrait;
* @method static PotionType LONG_POISON()
* @method static PotionType LONG_REGENERATION()
* @method static PotionType LONG_SLOWNESS()
* @method static PotionType LONG_SLOW_FALLING()
* @method static PotionType LONG_STRENGTH()
* @method static PotionType LONG_SWIFTNESS()
* @method static PotionType LONG_TURTLE_MASTER()
* @method static PotionType LONG_WATER_BREATHING()
* @method static PotionType LONG_WEAKNESS()
* @method static PotionType MUNDANE()
@ -55,6 +57,7 @@ use pocketmine\utils\EnumTrait;
* @method static PotionType POISON()
* @method static PotionType REGENERATION()
* @method static PotionType SLOWNESS()
* @method static PotionType SLOW_FALLING()
* @method static PotionType STRENGTH()
* @method static PotionType STRONG_HARMING()
* @method static PotionType STRONG_HEALING()
@ -63,8 +66,10 @@ use pocketmine\utils\EnumTrait;
* @method static PotionType STRONG_REGENERATION()
* @method static PotionType STRONG_STRENGTH()
* @method static PotionType STRONG_SWIFTNESS()
* @method static PotionType STRONG_TURTLE_MASTER()
* @method static PotionType SWIFTNESS()
* @method static PotionType THICK()
* @method static PotionType TURTLE_MASTER()
* @method static PotionType WATER()
* @method static PotionType WATER_BREATHING()
* @method static PotionType WEAKNESS()
@ -177,6 +182,21 @@ final class PotionType{
]),
new self("wither", fn() => [
new EffectInstance(VanillaEffects::WITHER(), 800, 1)
]),
new self("turtle_master", fn() => [
//TODO
]),
new self("long_turtle_master", fn() => [
//TODO
]),
new self("strong_turtle_master", fn() => [
//TODO
]),
new self("slow_falling", fn() => [
//TODO
]),
new self("long_slow_falling", fn() => [
//TODO
])
);
}