79 $effects = $this->getPotionEffects();
82 if(count($effects) === 0){
87 foreach($effects as $effect){
88 $level = $effect->getEffectLevel();
89 for($j = 0; $j < $level; ++$j){
90 $colors[] = $effect->getColor();
93 $particle =
new PotionSplashParticle(Color::mix(...$colors));
96 $this->getWorld()->addParticle($this->location, $particle);
97 $this->broadcastSound(
new PotionSplashSound());
99 if(!$this->willLinger()){
101 foreach($this->getWorld()->getCollidingEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){
102 if($entity instanceof Living){
103 $distanceSquared = $entity->getEyePos()->distanceSquared($this->location);
104 if($distanceSquared > 16){
108 $distanceMultiplier = 1 - (sqrt($distanceSquared) / 4);
109 if($event instanceof ProjectileHitEntityEvent && $entity === $event->getEntityHit()){
110 $distanceMultiplier = 1.0;
113 foreach($this->getPotionEffects() as $effect){
116 if(!($effect->getType() instanceof InstantEffect)){
117 $newDuration = (int) round($effect->getDuration() * 0.75 * $distanceMultiplier);
118 if($newDuration < 20){
121 $effect->setDuration($newDuration);
122 $entity->getEffects()->add($effect);
124 $effect->getType()->applyEffect($entity, $effect, $distanceMultiplier, $this);
131 $entity =
new AreaEffectCloud(Location::fromObject($this->location->floor()->add(0.5, 0.5, 0.5), $this->getWorld()));
132 foreach($this->potionType->getEffects() as $effect){
133 $entity->getEffects()->add($effect);
135 if(($owner = $this->getOwningEntity()) !==
null && !$owner->isClosed()){
136 $entity->setOwningEntity($owner);
138 $entity->spawnToAll();
140 if(!$hasEffects && $event instanceof ProjectileHitBlockEvent && $this->getPotionType() === PotionType::WATER){
141 $blockIn = $event->getBlockHit()->getSide($event->
getRayTraceResult()->getHitFace());
143 if($blockIn->hasTypeTag(BlockTypeTags::FIRE)){
144 $this->getWorld()->setBlock($blockIn->getPosition(), VanillaBlocks::AIR());
146 foreach($blockIn->getHorizontalSides() as $horizontalSide){
147 if($horizontalSide->hasTypeTag(BlockTypeTags::FIRE)){
148 $this->getWorld()->setBlock($horizontalSide->getPosition(), VanillaBlocks::AIR());