Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Fix #2030 (#2054)
Browse files Browse the repository at this point in the history
* Fix effects being applied multiple times from splash potions

* Remove useless condition from Thrown Potion
  • Loading branch information
JackNoordhuis authored and dktapps committed Oct 15, 2016
1 parent 243a7ce commit c440730
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/pocketmine/entity/ThrownPotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,26 @@ public function __construct(FullChunk $chunk, CompoundTag $nbt, Entity $shooting
unset($this->dataProperties[self::DATA_SHOOTER_ID]);
$this->setDataProperty(self::DATA_POTION_ID, self::DATA_TYPE_SHORT, $this->getPotionId());
}

public function getPotionId() : int{
return (int) $this->namedtag["PotionId"];
}

public function kill(){
$color = Potion::getColor($this->getPotionId());
$this->getLevel()->addParticle(new SpellParticle($this, $color[0], $color[1], $color[2]));
$players = $this->getViewers();
foreach($players as $p) {
if($p->distance($this) <= 6){
foreach(Potion::getEffectsById($this->getPotionId()) as $effect){
$p->addEffect($effect);
if($this->isAlive()) {
$color = Potion::getColor($this->getPotionId());
$this->getLevel()->addParticle(new SpellParticle($this, $color[0], $color[1], $color[2]));
$players = $this->getViewers();
foreach($players as $p) {
if($p->distance($this) <= 6) {
foreach(Potion::getEffectsById($this->getPotionId()) as $effect) {
$p->addEffect($effect);
}
}
}

parent::kill();
}

parent::kill();
}

public function onUpdate($currentTick){
Expand All @@ -87,11 +89,6 @@ public function onUpdate($currentTick){
$this->close();
$hasUpdate = true;
}

if($this->onGround) {
$this->kill();
$this->close();
}

$this->timings->stopTiming();

Expand Down

0 comments on commit c440730

Please sign in to comment.