Skip to content

LightningBolt 5.46.0 ​

class · pocketmine\entity\object\LightningBolt · source

Extends Entity
Implements NeverSavedWithChunkEntity

Lightning bolt (minecraft:lightning_bolt), vanilla behaviour: thunder and impact sounds, then the bolt lives 2 ticks plus 0-2 extra flashes. While it lives it strikes every entity within 3 blocks (up to 6 above), once each: Entity::onStruckByLightning() (5 damage and 8 seconds of fire by default, conversions for some mobs). On Normal and Hard it sets fire to the block it hits and up to 4 around it (one more on each flash). The block below is struck: a lightning rod gets a redstone pulse, and the copper it is attached to (or copper struck directly) loses its oxidation, along with a few random copper blocks around it.

A visual-only bolt (skeleton trap) only shows and sounds. Never saved.

Constants ​

DAMAGE ​

php
public const DAMAGE = 5.0

FIRE_SECONDS ​

php
public const FIRE_SECONDS = 8

STRIKE_HEIGHT ​

php
public const STRIKE_HEIGHT = 6.0

STRIKE_RADIUS ​

php
public const STRIKE_RADIUS = 3.0

Entities this far away horizontally (and up to 6 more above) are struck.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Location $location, bool $visualOnly = false, ?\pocketmine\nbt\tag\CompoundTag $nbt = null)

attack() ​

php
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : void

canBeCollidedWith() ​

php
public function canBeCollidedWith() : bool

canSaveWithChunk() ​

php
public function canSaveWithChunk() : bool

entityBaseTick() protected ​

php
protected function entityBaseTick(int $tickDiff = 1) : bool

getInitialDragMultiplier() protected ​

php
protected function getInitialDragMultiplier() : float

getInitialGravity() protected ​

php
protected function getInitialGravity() : float

getInitialSizeInfo() protected ​

php
protected function getInitialSizeInfo() : \pocketmine\entity\EntitySizeInfo

getNetworkTypeId() ​

php
public static function getNetworkTypeId() : string

getStrikePosition() ​

php
public function getStrikePosition() : \pocketmine\math\Vector3

The block the bolt strikes (the one below it).

hasMovementUpdate() ​

php
public function hasMovementUpdate() : bool

isFireProof() ​

php
public function isFireProof() : bool

isVisualOnly() ​

php
public function isVisualOnly() : bool

strike() ​

php
public static function strike(\pocketmine\entity\Location $location, bool $visualOnly = false, int $cause = \pocketmine\event\world\LightningStrikeEvent::CAUSE_CUSTOM) : ?self

Spawns a lightning bolt at the given position, after a LightningStrikeEvent. Returns null if a plugin cancelled it.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.