jorgebyte/fireworkslib
Composer 安装命令:
composer require jorgebyte/fireworkslib
包简介
Advanced fireworks management library for PocketMine-MP with async support
README 文档
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_SIZEand 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
FireworkParticleAnimationfor 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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-09-13