From efa8721d3658b45146d58d6731a0b83c4860f02e Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 16 Feb 2026 01:03:05 -0500 Subject: [PATCH] Add energy projectile types and events: implement IEnergyOrb, IEnergyBeam, IEnergyDisc, and IEnergyLaser interfaces, along with their respective script handlers and event hooks --- java/noppes/npcs/api/IWorld.java | 46 +++++++ java/noppes/npcs/api/entity/ICustomNpc.java | 7 + java/noppes/npcs/api/entity/IEnergyBeam.java | 23 ++++ java/noppes/npcs/api/entity/IEnergyDisc.java | 31 +++++ java/noppes/npcs/api/entity/IEnergyLaser.java | 45 +++++++ java/noppes/npcs/api/entity/IEnergyOrb.java | 10 ++ .../npcs/api/entity/IEnergyProjectile.java | 123 +++++++++++++++++- java/noppes/npcs/api/entity/IPlayer.java | 7 + .../api/event/IEnergyProjectileEvent.java | 48 +++++++ .../npcs/api/event/IPlayerAbilityEvent.java | 67 ++++++++++ 10 files changed, 402 insertions(+), 5 deletions(-) create mode 100644 java/noppes/npcs/api/entity/IEnergyBeam.java create mode 100644 java/noppes/npcs/api/entity/IEnergyDisc.java create mode 100644 java/noppes/npcs/api/entity/IEnergyLaser.java create mode 100644 java/noppes/npcs/api/entity/IEnergyOrb.java create mode 100644 java/noppes/npcs/api/event/IEnergyProjectileEvent.java diff --git a/java/noppes/npcs/api/IWorld.java b/java/noppes/npcs/api/IWorld.java index b25d3a8..ae01d2e 100644 --- a/java/noppes/npcs/api/IWorld.java +++ b/java/noppes/npcs/api/IWorld.java @@ -1,6 +1,10 @@ package noppes.npcs.api; import net.minecraft.world.WorldServer; +import noppes.npcs.api.entity.IEnergyBeam; +import noppes.npcs.api.entity.IEnergyDisc; +import noppes.npcs.api.entity.IEnergyLaser; +import noppes.npcs.api.entity.IEnergyOrb; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.data.ISound; @@ -445,5 +449,47 @@ public interface IWorld { */ int getDimensionID(); + /** + * Creates an energy orb projectile. Not spawned until fire() is called. + * @param owner The entity that owns this projectile + * @param x Spawn X position + * @param y Spawn Y position + * @param z Spawn Z position + * @param size Orb size + */ + IEnergyOrb createEnergyOrb(IEntity owner, double x, double y, double z, float size); + + /** + * Creates an energy beam projectile. Not spawned until fire() is called. + * @param owner The entity that owns this projectile + * @param x Spawn X position + * @param y Spawn Y position + * @param z Spawn Z position + * @param beamWidth Width of the beam + * @param headSize Size of the beam head + */ + IEnergyBeam createEnergyBeam(IEntity owner, double x, double y, double z, float beamWidth, float headSize); + + /** + * Creates an energy disc projectile. Not spawned until fire() is called. + * @param owner The entity that owns this projectile + * @param x Spawn X position + * @param y Spawn Y position + * @param z Spawn Z position + * @param radius Disc radius + * @param thickness Disc thickness + */ + IEnergyDisc createEnergyDisc(IEntity owner, double x, double y, double z, float radius, float thickness); + + /** + * Creates an energy laser projectile. Not spawned until fire() is called. + * @param owner The entity that owns this projectile + * @param x Spawn X position + * @param y Spawn Y position + * @param z Spawn Z position + * @param laserWidth Width of the laser + */ + IEnergyLaser createEnergyLaser(IEntity owner, double x, double y, double z, float laserWidth); + void broadcast(String message); } diff --git a/java/noppes/npcs/api/entity/ICustomNpc.java b/java/noppes/npcs/api/entity/ICustomNpc.java index d4b5161..18ca698 100644 --- a/java/noppes/npcs/api/entity/ICustomNpc.java +++ b/java/noppes/npcs/api/entity/ICustomNpc.java @@ -4,6 +4,7 @@ import net.minecraft.entity.EntityCreature; import noppes.npcs.api.IPos; import noppes.npcs.api.ITimers; import noppes.npcs.api.ability.IDataAbilities; +import noppes.npcs.api.entity.IEnergyProjectile; import noppes.npcs.api.entity.data.IModelData; import noppes.npcs.api.handler.IActionManager; import noppes.npcs.api.handler.IOverlayHandler; @@ -1515,4 +1516,10 @@ public interface ICustomNpc extends IEntityLiving, * @return Ability data */ IDataAbilities getAbilityData(); + + /** + * Returns all active energy projectiles fired by this NPC. + * @return Array of active energy projectiles, empty array if none + */ + IEnergyProjectile[] getActiveEnergyProjectiles(); } diff --git a/java/noppes/npcs/api/entity/IEnergyBeam.java b/java/noppes/npcs/api/entity/IEnergyBeam.java new file mode 100644 index 0000000..f951dcb --- /dev/null +++ b/java/noppes/npcs/api/entity/IEnergyBeam.java @@ -0,0 +1,23 @@ +package noppes.npcs.api.entity; + +import net.minecraft.entity.Entity; + +/** + * Represents an energy beam projectile - a directional beam with a trailing path. + */ +public interface IEnergyBeam extends IEnergyProjectile { + + float getBeamWidth(); + + void setBeamWidth(float width); + + float getHeadSize(); + + void setHeadSize(float size); + + boolean isAttachedToOwner(); + + void setAttachedToOwner(boolean attached); + + boolean shouldRenderTailOrb(); +} diff --git a/java/noppes/npcs/api/entity/IEnergyDisc.java b/java/noppes/npcs/api/entity/IEnergyDisc.java new file mode 100644 index 0000000..cfb772f --- /dev/null +++ b/java/noppes/npcs/api/entity/IEnergyDisc.java @@ -0,0 +1,31 @@ +package noppes.npcs.api.entity; + +import net.minecraft.entity.Entity; + +/** + * Represents an energy disc projectile - a flat spinning disc with optional boomerang behavior. + */ +public interface IEnergyDisc extends IEnergyProjectile { + + float getDiscRadius(); + + void setDiscRadius(float radius); + + float getDiscThickness(); + + void setDiscThickness(float thickness); + + boolean isVertical(); + + void setVertical(boolean vertical); + + boolean isBoomerang(); + + void setBoomerang(boolean boomerang); + + int getBoomerangDelay(); + + void setBoomerangDelay(int ticks); + + boolean isReturning(); +} diff --git a/java/noppes/npcs/api/entity/IEnergyLaser.java b/java/noppes/npcs/api/entity/IEnergyLaser.java new file mode 100644 index 0000000..0327999 --- /dev/null +++ b/java/noppes/npcs/api/entity/IEnergyLaser.java @@ -0,0 +1,45 @@ +package noppes.npcs.api.entity; + +import net.minecraft.entity.Entity; + +/** + * Represents an energy laser projectile - a fast expanding piercing line. + */ +public interface IEnergyLaser extends IEnergyProjectile { + + float getLaserWidth(); + + void setLaserWidth(float width); + + float getExpansionSpeed(); + + void setExpansionSpeed(float speed); + + int getLingerTicks(); + + void setLingerTicks(int ticks); + + float getCurrentLength(); + + boolean isFullyExtended(); + + double getDirX(); + + double getDirY(); + + double getDirZ(); + + void setDirection(double x, double y, double z); + + double getEndX(); + + double getEndY(); + + double getEndZ(); + + float getLingerAlpha(); + + boolean isLockVerticalDirection(); + + void setLockVerticalDirection(boolean lock); +} diff --git a/java/noppes/npcs/api/entity/IEnergyOrb.java b/java/noppes/npcs/api/entity/IEnergyOrb.java new file mode 100644 index 0000000..70af189 --- /dev/null +++ b/java/noppes/npcs/api/entity/IEnergyOrb.java @@ -0,0 +1,10 @@ +package noppes.npcs.api.entity; + +import net.minecraft.entity.Entity; + +/** + * Represents an energy orb projectile - a spherical homing energy ball. + * Orbs use the base IEnergyProjectile properties with no additional methods. + */ +public interface IEnergyOrb extends IEnergyProjectile { +} diff --git a/java/noppes/npcs/api/entity/IEnergyProjectile.java b/java/noppes/npcs/api/entity/IEnergyProjectile.java index 7d40962..b55ca94 100644 --- a/java/noppes/npcs/api/entity/IEnergyProjectile.java +++ b/java/noppes/npcs/api/entity/IEnergyProjectile.java @@ -1,35 +1,61 @@ package noppes.npcs.api.entity; +import net.minecraft.entity.Entity; + +/** + * Represents an energy projectile entity (Orb, Beam, Disc, Laser). + * Extends IEntity so scripts have full access to both entity and energy-specific methods. + */ +public interface IEnergyProjectile extends IEntity { + + // ==================== OWNER & TARGET ==================== -public interface IEnergyProjectile { int getOwnerEntityId(); IEntity getOwner(); + void setOwner(IEntity owner); + int getTargetEntityId(); IEntity getTarget(); + void setTarget(IEntity target); + + // ==================== SIZE ==================== + float getSize(); - double getMotionX(); + void setSize(float size); - double getMotionY(); - - double getMotionZ(); + // ==================== DISPLAY ==================== int getInnerColor(); + void setInnerColor(int color); + int getOuterColor(); + void setOuterColor(int color); + boolean isOuterColorEnabled(); + void setOuterColorEnabled(boolean enabled); + float getOuterColorWidth(); + void setOuterColorWidth(float width); + float getOuterColorAlpha(); + void setOuterColorAlpha(float alpha); + float getRotationSpeed(); + void setRotationSpeed(float speed); + + // ==================== INTERPOLATION (READ-ONLY) ==================== + float getInterpolatedRotationX(float partialTicks); float getInterpolatedRotationY(float partialTicks); @@ -38,38 +64,80 @@ public interface IEnergyProjectile { float getInterpolatedSize(float partialTicks); + // ==================== LIGHTNING ==================== + boolean hasLightningEffect(); + void setLightningEffect(boolean enabled); + float getLightningDensity(); + void setLightningDensity(float density); + float getLightningRadius(); + void setLightningRadius(float radius); + int getLightningFadeTime(); + void setLightningFadeTime(int ticks); + + // ==================== LIFESPAN ==================== + float getMaxDistance(); + void setMaxDistance(float distance); + int getMaxLifetime(); + void setMaxLifetime(int ticks); + + // ==================== COMBAT ==================== + float getDamage(); + void setDamage(float damage); + float getKnockback(); + void setKnockback(float knockback); + float getKnockbackUp(); + void setKnockbackUp(float knockbackUp); + boolean isExplosive(); + void setExplosive(boolean explosive); + float getExplosionRadius(); + void setExplosionRadius(float radius); + float getExplosionDamageFalloff(); + void setExplosionDamageFalloff(float falloff); + + // ==================== MOVEMENT ==================== + float getSpeed(); + void setSpeed(float speed); + boolean isHoming(); + void setHoming(boolean homing); + float getHomingStrength(); + void setHomingStrength(float strength); + float getHomingRange(); + void setHomingRange(float range); + + // ==================== ANCHOR ==================== + int getAnchor(); float getAnchorOffsetX(); @@ -78,9 +146,54 @@ public interface IEnergyProjectile { float getAnchorOffsetZ(); + // ==================== POSITION ==================== + double getStartX(); double getStartY(); double getStartZ(); + + // ==================== STATE ==================== + + boolean hasHit(); + + boolean isCharging(); + + float getChargeProgress(); + + /** + * Returns the energy projectile sub-type. + * 0=Orb, 1=Beam, 2=Disc, 3=Laser + */ + int getEnergyType(); + + // ==================== FIRE / LAUNCH ==================== + + /** + * Spawns the projectile in the world (if not yet spawned) and starts it moving toward the target entity. + */ + void fire(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); + + /** + * Spawns the projectile in the world (if not yet spawned) and starts it moving in the specified direction. + */ + void fire(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); + + /** + * Sets the owner, positions the projectile at the caster's eye level, and fires toward the target entity. + */ + void fire(IEntityLivingBase caster, IEntity target); + } diff --git a/java/noppes/npcs/api/entity/IPlayer.java b/java/noppes/npcs/api/entity/IPlayer.java index 9026f9a..765f013 100644 --- a/java/noppes/npcs/api/entity/IPlayer.java +++ b/java/noppes/npcs/api/entity/IPlayer.java @@ -9,6 +9,7 @@ import noppes.npcs.api.IPos; import noppes.npcs.api.IScreenSize; import noppes.npcs.api.ITimers; import noppes.npcs.api.IWorld; +import noppes.npcs.api.entity.IEnergyProjectile; import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.handler.IActionManager; import noppes.npcs.api.handler.IOverlayHandler; @@ -752,4 +753,10 @@ public interface IPlayer extends IEntityLivingBase, * @return The formatted balance string */ String getFormattedCurrencyBalance(); + + /** + * Returns all active energy projectiles fired by this player. + * @return Array of active energy projectiles, empty array if none + */ + IEnergyProjectile[] getActiveEnergyProjectiles(); } diff --git a/java/noppes/npcs/api/event/IEnergyProjectileEvent.java b/java/noppes/npcs/api/event/IEnergyProjectileEvent.java new file mode 100644 index 0000000..80461f2 --- /dev/null +++ b/java/noppes/npcs/api/event/IEnergyProjectileEvent.java @@ -0,0 +1,48 @@ +package noppes.npcs.api.event; + +import noppes.npcs.api.IBlock; +import noppes.npcs.api.entity.IEnergyProjectile; +import noppes.npcs.api.entity.IEntity; + +public interface IEnergyProjectileEvent extends ICustomNPCsEvent { + + IEnergyProjectile getProjectile(); + + IEntity getOwner(); + + /** + * @hookName energyProjectileFired + */ + interface FiredEvent extends IEnergyProjectileEvent { + } + + /** + * @hookName energyProjectileTick + */ + interface UpdateEvent extends IEnergyProjectileEvent { + } + + /** + * @hookName energyProjectileEntityImpact + */ + interface EntityImpactEvent extends IEnergyProjectileEvent { + IEntity getTarget(); + + float getDamage(); + + void setDamage(float damage); + } + + /** + * @hookName energyProjectileBlockImpact + */ + interface BlockImpactEvent extends IEnergyProjectileEvent { + IBlock getBlock(); + } + + /** + * @hookName energyProjectileExpired + */ + interface ExpiredEvent extends IEnergyProjectileEvent { + } +} diff --git a/java/noppes/npcs/api/event/IPlayerAbilityEvent.java b/java/noppes/npcs/api/event/IPlayerAbilityEvent.java index 621e217..00c7a6b 100644 --- a/java/noppes/npcs/api/event/IPlayerAbilityEvent.java +++ b/java/noppes/npcs/api/event/IPlayerAbilityEvent.java @@ -1,6 +1,7 @@ package noppes.npcs.api.event; import cpw.mods.fml.common.eventhandler.Cancelable; +import noppes.npcs.api.IDamageSource; import noppes.npcs.api.ability.IAbility; import noppes.npcs.api.entity.IEntityLivingBase; @@ -20,9 +21,75 @@ public interface IPlayerAbilityEvent extends IPlayerEvent { */ IEntityLivingBase getTarget(); + /** + * Fired when a player's ability starts executing (enters WINDUP phase). + * Canceling prevents the ability from starting. + * + * @hookName abilityStart + */ + @Cancelable + interface StartEvent extends IPlayerAbilityEvent { + } + + /** + * Fired when a player's ability enters the ACTIVE phase and performs its effect. + * Canceling prevents the ability effect from occurring. + * + * @hookName abilityExecute + */ + @Cancelable + interface ExecuteEvent extends IPlayerAbilityEvent { + } + + /** + * Fired when a player's ability is interrupted by damage. + * + * @hookName abilityInterrupt + */ + interface InterruptEvent extends IPlayerAbilityEvent { + /** + * Get the damage source that caused the interruption, or null if not damage-triggered. + */ + IDamageSource getDamageSource(); + + /** + * Get the amount of damage that caused the interruption. + */ + float getDamage(); + } + + /** + * Fired when a player's ability completes its full execution cycle. + * + * @hookName abilityComplete + */ + interface CompleteEvent extends IPlayerAbilityEvent { + } + + /** + * Fired every tick while a player's ability is executing. + * Provides the current phase and tick count. + * + * @hookName abilityTick + */ + interface TickEvent extends IPlayerAbilityEvent { + /** + * Get the current phase of the ability. + * 0 = IDLE, 1 = WINDUP, 2 = ACTIVE, 3 = RECOVERY + */ + int getAbilityPhase(); + + /** + * Get the current tick count within the phase. + */ + int getTick(); + } + /** * Fired when a player's ability hits an entity with damage. * Canceling this event prevents the damage from being applied. + * + * @hookName abilityHit */ @Cancelable interface HitEvent extends IPlayerAbilityEvent {