jorgebyte / fireworkslib
Advanced fireworks management library for PocketMine-MP with async support
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/jorgebyte/fireworkslib
Requires
- php: ^8.1
- pocketmine/pocketmine-mp: ^5.0.0
Requires (Dev)
- phpstan/phpstan: ^1.10
This package is auto-updated.
Last update: 2025-09-13 23:32:15 UTC
README
FireworksLib: Advanced Fireworks Management for PocketMine-MP
A high-performance library for creating and controlling customizable fireworks displays in PocketMine-MP servers.
๐ฆ Installation
- Install via Composer:
composer require jorgebyte/fireworkslib
- Register in your plugin:
use Jorgebyte\FireworksLib\FireworksLib; public function onEnable(): void { FireworksLib::register(); }
โจ Key Features
- Synchronous & Asynchronous Launching
- Customizable Explosions (colors, shapes, effects)
- Batch Processing with configurable delays
- Particle/Sound Synchronization
- Mathematical Trajectory Control (radial distribution, angles)
๐ Usage Examples
1. Basic Firework Launch
use Jorgebyte\FireworksLib\FireworksManager; use Jorgebyte\FireworksLib\FireworksRegistry; use pocketmine\world\Position; $center = new Position($x, $y, $z, $world); $firework = FireworksRegistry::FIREWORKS(); FireworksManager::launch($center->asLocation(), $firework);
2. Customized Firework Item
use Jorgebyte\FireworksLib\FireworkType; use pocketmine\color\Color; $customFirework = FireworksRegistry::FIREWORKS(); $customFirework->setFlightDuration(3); // 3-second fuse $customFirework->addExplosion( type: FireworkType::STAR, color: new Color(255, 0, 0), // Red fade: new Color(0, 0, 255), // Blue fade flicker: true, trail: true );
3. Asynchronous Batch Launch (Radial Pattern)
use SOFe\AwaitStd\AwaitStd; Await::f2c(function () use ($center, $std) { yield from FireworksManager::launchMultipleAsync( std: $std, center: $center, firework: FireworksRegistry::FIREWORKS(), count: 30, radius: 5.0, delayBetweenBatches: 0.2 )->asGenerator(); });
๐งฉ API Reference
๐ง FireworksManager
Method | Parameters | Description |
---|---|---|
launch |
Location $location , FireworksItem $firework |
Sync single firework launch |
launchAsync |
Location $location , FireworksItem $firework |
Async generator (Traverser) |
launchMultipleAsync |
AwaitStd $std , Location $center , FireworksItem $firework , int $count , float $radius=3.0 , float $delayBetweenBatches=0.5 |
Batch launch in radial pattern |
๐งช FireworksItem
Methods
// Set flight duration (1-3 recommended) $item->setFlightDuration(int $duration); // Add explosion effect: $item->addExplosion( int $type, // FireworkType::CONSTANT Color $color, // Primary RGB ?Color $fade = null,// Fade color bool $flicker = false, bool $trail = false );
๐ฅ FireworkType
Constants
Constant | Effect |
---|---|
SMALL_SPHERE |
Standard spherical burst |
HUGE_SPHERE |
Large-scale sphere |
STAR |
Star-shaped explosion |
CREEPER_HEAD |
Creeper-face pattern |
BURST |
Crackle-effect explosion |
๐ฏ Benefits
- Performance Optimization
- Batch processing with
BATCH_SIZE
and tick delays - Async coroutines prevent server lag
- Batch processing with
- Precision Control
- Radial coordinate calculation via
$angleStep = (2 * M_PI) / $count
- Customizable delay intervals between batches
- Radial coordinate calculation via
- Extensibility
- Implement custom trajectories by extending
FireworksRocket
- Modify
FireworkParticleAnimation
for custom effects
- Implement custom trajectories by extending
๐งช Advanced Implementation
Extending FireworksRocket
class CustomRocket extends FireworksRocket { protected function explode(): void { // Custom explosion logic parent::explode(); // Call default behavior } }
Direct NBT Manipulation
$nbt = $firework->getNamedTag(); $nbt->getCompoundTag("Fireworks")?->setByte("Flight", 2);
๐ค Contribution
- Fork the repository
- Adhere to PER-CS2.0 coding standards
- Submit pull requests with detailed descriptions
Supported by:
Await Generator
Transform your server events with mathematically precise firework displays! ๐
Developed by Jorgebyte