-
Notifications
You must be signed in to change notification settings - Fork 0
N | Utility: ProjectileUtils
Sartaj Singh edited this page May 31, 2025
·
2 revisions
- 1. Overview
- 2. What is ProjectileUtils?
- 3. Basic Usage
- 4. API Reference
- 5. Advanced Patterns
- 6. Troubleshooting & Notes
- 7. See Also
ProjectileUtils is a utility class in FXItems for creating custom projectiles with enhanced behaviors, effects, and integration with other plugins such as ModelEngine.
It centralizes projectile spawning logic, allowing you to easily define particles, damage, speed, and more for custom item abilities.
- Spawns projectiles (arrows or custom entities) with custom properties.
- Supports custom damage, particle trails, gravity, glowing, knockback, and more.
- Integrates with ModelEngine for visual custom projectiles if the plugin is installed.
- Handles projectile despawn timing and custom behaviors on impact.
ProjectileUtils.createCustomProjectile(
plugin,
player, // Shooter
Particle.FLAME, // Trail particle
2, // Particle count
true, // Gravity
false, // Glowing
1, // Knockback strength
false, // Silent
2.0, // Speed
8.0, // Damage
false, // Speed-based damage
EntityType.ARROW, // Projectile type
false, // Use ModelEngine
"", // ModelEngine modelId
60, // Despawn time (ticks)
0 // Piercing level
);/**
* Creates a custom projectile with specified properties.
*
* @param plugin The plugin instance.
* @param shooter The player launching the projectile.
* @param trailParticle Particle trail type.
* @param particleCount Number of particles per tick.
* @param gravity Whether gravity affects the projectile.
* @param glowing Whether the projectile glows.
* @param knockbackStrength Knockback level for arrows.
* @param silent If true, projectile is silent.
* @param speed Launch speed.
* @param damage Base damage (used if not speedBasedDamage).
* @param speedBasedDamage If true, damage scales with speed.
* @param projectileType Bukkit EntityType (e.g., ARROW, SNOWBALL).
* @param useModelEngine If true, uses ModelEngine for visuals.
* @param modelId ModelEngine model id (if used).
* @param despawnTime Time in ticks before the projectile despawns.
* @param piercingLevel Pierce level (arrows only).
* @throws ProjectileException if ModelEngine is required but not present, or modelId is invalid.
*/
public static void createCustomProjectile(
Plugin plugin,
Player shooter,
Particle trailParticle,
int particleCount,
boolean gravity,
boolean glowing,
int knockbackStrength,
boolean silent,
double speed,
double damage,
boolean speedBasedDamage,
EntityType projectileType,
boolean useModelEngine,
String modelId,
int despawnTime,
int piercingLevel
)-
ModelEngine Projectiles:
SetuseModelEngineto true and provide a validmodelIdto use a ModelEngine entity as the projectile.
If ModelEngine is not installed, an exception is thrown. -
Custom Damage:
For arrows, custom damage is handled via metadata and applied on impact. -
Particle Trails:
Particle effects are spawned along the projectile's path every tick. -
Despawning:
Projectiles are automatically despawned after the configured time.
- If ModelEngine is not installed and
useModelEngineis true, an exception is thrown with a clear message. - If using ModelEngine,
modelIdmust be a valid string; otherwise, the projectile will not spawn. - Custom damage for arrows is only applied if
speedBasedDamageis false. - All behavior (particle, glowing, damage) is handled within the utility; no need to manually manage these with listeners.
- Home
- A | Getting Started & Plugin Overview
- B | The Registry System: Items, Foods, Commands, Events
- C | Creating Custom Items
- D | Creating Custom Foods
- E | Advanced: Custom Effects in FXItems
- F | Creating Custom Commands
- G | Creating Custom Events & Behaviors
- H | Utility: CooldownUtils
- I | Utility: CustomItemUtils
- J | Utility: EffectUtils
- K | Utility: ManaUtils
- L | Utility: OneTimeCraftUtils
- M | Utility: TeleportUtils
- N | Utility: ProjectileUtils
- O | Utility: GammaUtils
- P | Utility: EntitySizeUtils
- Q | FXItems API (com.noctify.API) & Making Addons
- R | Advanced Techniques, Gotchas & FAQ
- S | Auto-Registration System
- T | Migration Guide (v1.1 → v1.2+)
- U | Changelog