InfestedEffect 5.47.0
Extends Effect
Implements DamageAwareEffect
Infested (https://minecraft.wiki/w/Infested): each time the entity is hurt there is a 10% chance that 1-2 silverfish come out of it, halfway up its body, pushed out in front of it (Java InfestedMobEffect: look direction x0.3, 1.5x upwards, turned by a random angle up to 90 degrees). The amplifier doesn't change the chance or the count. Nothing spawns in peaceful, where silverfish despawn. Silverfish themselves are immune to it, so they never chain.
Constants
SPAWN_CHANCE
php
public const SPAWN_CHANCE = 0.1Methods
onEntityDamaged()
php
public function onEntityDamaged(\pocketmine\entity\Living $entity, \pocketmine\entity\effect\EffectInstance $instance, \pocketmine\event\entity\EntityDamageEvent $source) : voidrollSilverfishCount()
php
public static function rollSilverfishCount() : intReturns how many silverfish one hit lets out: 0 (90%), 1 or 2.
spawnSilverfish()
php
public static function spawnSilverfish(\pocketmine\entity\Living $entity, int $count) : arraySpawns the given number of silverfish out of the entity and returns them (none in peaceful).
