From 4e96425314a9fd2d3e48f68cff5fc7ee69f87213 Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 3 Mar 2026 17:11:12 -0500 Subject: [PATCH] Energy Explosion API and some changes to Energy Projectile API --- java/noppes/npcs/api/IEnergyController.java | 9 +++ .../npcs/api/entity/IEnergyExplosion.java | 60 +++++++++++++++++++ .../npcs/api/entity/IEnergyProjectile.java | 10 ++-- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 java/noppes/npcs/api/entity/IEnergyExplosion.java diff --git a/java/noppes/npcs/api/IEnergyController.java b/java/noppes/npcs/api/IEnergyController.java index d6fc769..5c3156f 100644 --- a/java/noppes/npcs/api/IEnergyController.java +++ b/java/noppes/npcs/api/IEnergyController.java @@ -1,6 +1,7 @@ package noppes.npcs.api; import noppes.npcs.api.entity.*; +import noppes.npcs.api.entity.IEnergyExplosion; /** * Central controller for creating energy entities and routing energy damage. @@ -63,4 +64,12 @@ public interface IEnergyController { * Panels are flat energy barriers that can deal damage on contact. */ IEnergyPanel createPanel(IWorld world, IEntity owner, double x, double y, double z); + + // ==================== EXPLOSION CREATION ==================== + + /** + * Create an energy explosion entity. Not spawned until spawn() is called. + * Visual-only by default. Set damage > 0 to enable area damage with falloff. + */ + IEnergyExplosion createExplosion(IWorld world, IEntity owner, double x, double y, double z, float radius); } diff --git a/java/noppes/npcs/api/entity/IEnergyExplosion.java b/java/noppes/npcs/api/entity/IEnergyExplosion.java new file mode 100644 index 0000000..6121dc9 --- /dev/null +++ b/java/noppes/npcs/api/entity/IEnergyExplosion.java @@ -0,0 +1,60 @@ +package noppes.npcs.api.entity; + +import net.minecraft.entity.Entity; +import noppes.npcs.api.INbt; + +/** + * Represents a standalone energy explosion entity. + * Created via {@link noppes.npcs.api.IEnergyController#createExplosion}. + * Configure visual/damage properties, then call {@link #spawn()} to place in the world. + * + * When damage is set (> 0), the explosion will deal area damage on the first tick + * with distance-based falloff, routing through energy damage handlers for addon integration. + */ +public interface IEnergyExplosion extends IEnergyAbility { + + // ==================== RADIUS & DURATION ==================== + + /** @return The maximum explosion radius in blocks. */ + float getRadius(); + + /** @param radius Maximum explosion radius in blocks (clamped 0.5-50). Duration auto-scales. */ + void setRadius(float radius); + + /** @return Duration of the explosion visual in ticks (auto-calculated from radius). */ + int getDuration(); + + // ==================== DAMAGE ==================== + + /** @return Base damage dealt at the center. 0 means visual-only. */ + float getDamage(); + + /** @param damage Base damage at the center. Setting > 0 enables damage. */ + void setDamage(float damage); + + /** @return Base knockback strength. */ + float getKnockback(); + + /** @param knockback Base knockback strength. */ + void setKnockback(float knockback); + + /** @return Upward knockback component. */ + float getKnockbackUp(); + + /** @param knockbackUp Upward knockback component. */ + void setKnockbackUp(float knockbackUp); + + /** @return Damage falloff factor (0=no falloff, 1=full falloff at edge). */ + float getDamageFalloff(); + + /** @param falloff Damage falloff factor (0-1). At 0.5, edge damage = 50% of center. */ + void setDamageFalloff(float falloff); + + // ==================== SPAWNING ==================== + + /** + * Spawn this explosion entity into the world. + * Sends the visual to nearby clients and, if damage > 0, applies area damage on the first tick. + */ + void spawn(); +} diff --git a/java/noppes/npcs/api/entity/IEnergyProjectile.java b/java/noppes/npcs/api/entity/IEnergyProjectile.java index 136c815..6f1a3ca 100644 --- a/java/noppes/npcs/api/entity/IEnergyProjectile.java +++ b/java/noppes/npcs/api/entity/IEnergyProjectile.java @@ -139,27 +139,27 @@ public interface IEnergyProjectile extends IEnergyAbility { /** * Spawns the projectile in the world (if not yet spawned) and starts it moving toward the target entity. */ - void fire(IEntity target); + void fireAt(IEntity target); /** * Spawns the projectile in the world (if not yet spawned) and starts it moving toward the specified coordinates. */ - void fire(double x, double y, double z); + void fireAt(double x, double y, double z); /** * Spawns the projectile in the world (if not yet spawned) and starts it moving in the specified direction. */ - void fire(float yaw, float pitch); + void fireDirection(float yaw, float pitch); /** * Sets the owner, positions the projectile at the caster's eye level, and fires in the caster's look direction. * Convenience method similar to how fireKiAttack works. */ - void fire(IEntityLivingBase caster); + void fireFrom(IEntityLivingBase caster); /** * Sets the owner, positions the projectile at the caster's eye level, and fires toward the target entity. */ - void fire(IEntityLivingBase caster, IEntity target); + void fireFrom(IEntityLivingBase caster, IEntity target); }