diff --git a/src/entity/effect/EffectContainer.php b/src/entity/effect/EffectContainer.php index 145785e5cb..cc87069123 100644 --- a/src/entity/effect/EffectContainer.php +++ b/src/entity/effect/EffectContainer.php @@ -51,9 +51,7 @@ class EffectContainer{ */ protected ObjectSet $effectRemoveHooks; - protected Color $defaultBubbleColor; - - protected ?Color $bubbleColor = null; + protected Color $bubbleColor; protected bool $onlyAmbientEffects = false; @@ -65,7 +63,7 @@ class EffectContainer{ protected \Closure $effectValidatorForBubbles; public function __construct(){ - $this->defaultBubbleColor = new Color(0, 0, 0, 0); + $this->bubbleColor = new Color(0, 0, 0, 0); $this->effectAddHooks = new ObjectSet(); $this->effectRemoveHooks = new ObjectSet(); @@ -200,21 +198,13 @@ protected function recalculateEffectColor() : void{ $this->bubbleColor = Color::mix(...$colors); $this->onlyAmbientEffects = $ambient; }else{ - $this->bubbleColor = null; + $this->bubbleColor = new Color(0, 0, 0, 0); $this->onlyAmbientEffects = false; } } - public function getDefaultBubbleColor() : Color{ - return $this->defaultBubbleColor; - } - - public function setDefaultBubbleColor(Color $color) : void{ - $this->defaultBubbleColor = $color; - } - public function getBubbleColor() : Color{ - return $this->bubbleColor ?? $this->defaultBubbleColor; + return $this->bubbleColor; } public function hasOnlyAmbientEffects() : bool{ diff --git a/src/entity/object/AreaEffectCloud.php b/src/entity/object/AreaEffectCloud.php index a7e87f272d..736efdded6 100644 --- a/src/entity/object/AreaEffectCloud.php +++ b/src/entity/object/AreaEffectCloud.php @@ -115,7 +115,6 @@ protected function initEntity(CompoundTag $nbt) : void{ parent::initEntity($nbt); $this->effectContainer = new EffectContainer(); - $this->effectContainer->setDefaultBubbleColor(PotionSplashParticle::DEFAULT_COLOR()); $this->effectContainer->getEffectAddHooks()->add(function() : void{ $this->networkPropertiesDirty = true; }); $this->effectContainer->getEffectRemoveHooks()->add(function() : void{ $this->networkPropertiesDirty = true; }); $this->effectContainer->setEffectFilterForBubbles(function(EffectInstance $effect) : bool{ @@ -452,7 +451,9 @@ protected function syncNetworkData(EntityMetadataCollection $properties) : void{ $properties->setFloat(EntityMetadataProperties::AREA_EFFECT_CLOUD_RADIUS, $this->radius); $properties->setFloat(EntityMetadataProperties::AREA_EFFECT_CLOUD_PICKUP_COUNT, $this->pickupCount); $properties->setInt(EntityMetadataProperties::AREA_EFFECT_CLOUD_WAITING, $spawnTime + $this->waiting); - $properties->setInt(EntityMetadataProperties::POTION_COLOR, Binary::signInt($this->effectContainer->getBubbleColor()->toARGB())); + $properties->setInt(EntityMetadataProperties::POTION_COLOR, Binary::signInt(( + count($this->effectContainer->all()) === 0 ? PotionSplashParticle::DEFAULT_COLOR() : $this->effectContainer->getBubbleColor() + )->toARGB())); $properties->setByte(EntityMetadataProperties::POTION_AMBIENT, $this->effectContainer->hasOnlyAmbientEffects() ? 1 : 0); //TODO: HACK! we purposely fill these in with invalid values to disable the client-sided radius calculation.