Remove all Legacy Ability Content, cleanup API.

- Add Script Tab to Abilities
- Add Custom Ability
- Add Icon Support for Abilities / Default Icon Support
- Remove Icon Tab and throw it into Effects with allowed Override
- Removed Deprecated API Sources
This commit is contained in:
Kam committed 2026-02-27 16:43:35 -05:00
1 parent 936dc7f0cc
commit 675c4ef4f9
50 files changed
+1488 -938

No files matched your search

@@ -8,22 +8,48 @@ import noppes.npcs.api.IDamageSource;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IEntityLivingBase;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.event.IAbilityEvent;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.scripted.NpcAPI;
/**
* Events fired during NPC ability execution lifecycle.
* Unified ability events for both NPCs and Players.
*/
public class AbilityEvent extends NpcEvent implements IAbilityEvent {
public class AbilityEvent extends CustomNPCsEvent implements IAbilityEvent {
protected final IEntityLivingBase entity;
public final IPlayer player;
public final ICustomNpc<?> npc;
protected final Ability ability;
protected final IEntityLivingBase target;
private transient IAbility abilityCopy;
public AbilityEvent(ICustomNpc npc, Ability ability, EntityLivingBase target) {
super(npc);
public AbilityEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target) {
this.entity = entity != null ? (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity) : null;
this.ability = ability;
this.target = target != null ? (IEntityLivingBase) NpcAPI.Instance().getIEntity(target) : null;
this.player = (this.entity instanceof IPlayer) ? (IPlayer) this.entity : null;
this.npc = (this.entity instanceof ICustomNpc) ? (ICustomNpc<?>) this.entity : null;
}
@Override
public IEntityLivingBase getEntity() {
return entity;
}
@Override
public IPlayer getPlayer() {
return player;
}
@Override
public ICustomNpc<?> getNpc() {
return npc;
}
@Override
public boolean isNPC() {
return entity instanceof ICustomNpc;
}
@Override
@@ -44,13 +70,10 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
return "abilityEvent";
}
/**
* Fired when an ability starts executing (enters WINDUP phase).
*/
@Cancelable
public static class StartEvent extends AbilityEvent implements IAbilityEvent.StartEvent {
public StartEvent(ICustomNpc npc, Ability ability, EntityLivingBase target) {
super(npc, ability, target);
public StartEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target) {
super(entity, ability, target);
}
@Override
@@ -59,13 +82,10 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired when an ability enters the ACTIVE phase and performs its effect.
*/
@Cancelable
public static class ExecuteEvent extends AbilityEvent implements IAbilityEvent.ExecuteEvent {
public ExecuteEvent(ICustomNpc npc, Ability ability, EntityLivingBase target) {
super(npc, ability, target);
public ExecuteEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target) {
super(entity, ability, target);
}
@Override
@@ -74,16 +94,13 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired when an ability is interrupted by damage.
*/
public static class InterruptEvent extends AbilityEvent implements IAbilityEvent.InterruptEvent {
private final IDamageSource damageSource;
private final float damage;
public InterruptEvent(ICustomNpc npc, Ability ability, EntityLivingBase target, DamageSource source, float damage) {
super(npc, ability, target);
this.damageSource = NpcAPI.Instance().getIDamageSource(source);
public InterruptEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target, DamageSource source, float damage) {
super(entity, ability, target);
this.damageSource = source != null ? NpcAPI.Instance().getIDamageSource(source) : null;
this.damage = damage;
}
@@ -103,12 +120,9 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired when an ability completes its full execution cycle.
*/
public static class CompleteEvent extends AbilityEvent implements IAbilityEvent.CompleteEvent {
public CompleteEvent(ICustomNpc npc, Ability ability, EntityLivingBase target) {
super(npc, ability, target);
public CompleteEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target) {
super(entity, ability, target);
}
@Override
@@ -117,10 +131,6 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired when an ability hits an entity with damage.
* This is a cancelable event - canceling prevents the damage from being applied.
*/
@Cancelable
public static class HitEvent extends AbilityEvent implements IAbilityEvent.HitEvent {
private final IEntityLivingBase hitEntity;
@@ -128,9 +138,9 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
private float knockback;
private float knockbackUp;
public HitEvent(ICustomNpc npc, Ability ability, EntityLivingBase target,
public HitEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target,
EntityLivingBase hitEntity, float damage, float knockback, float knockbackUp) {
super(npc, ability, target);
super(entity, ability, target);
this.hitEntity = hitEntity != null ? (IEntityLivingBase) NpcAPI.Instance().getIEntity(hitEntity) : null;
this.damage = damage;
this.knockback = knockback;
@@ -178,16 +188,12 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired every tick while an ability is executing.
* Provides information about the current phase and tick.
*/
public static class TickEvent extends AbilityEvent implements IAbilityEvent.TickEvent {
private final int abilityPhase;
private final int tick;
public TickEvent(ICustomNpc npc, Ability ability, EntityLivingBase target, int phase, int tick) {
super(npc, ability, target);
public TickEvent(EntityLivingBase entity, Ability ability, EntityLivingBase target, int phase, int tick) {
super(entity, ability, target);
this.abilityPhase = phase;
this.tick = tick;
}
@@ -208,17 +214,13 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired when a toggle ability changes state.
* Canceling prevents the toggle from changing state.
*/
@Cancelable
public static class ToggleEvent extends AbilityEvent implements IAbilityEvent.ToggleEvent {
private final int oldState;
private final int newState;
public ToggleEvent(ICustomNpc npc, Ability ability, int oldState, int newState) {
super(npc, ability, null);
public ToggleEvent(EntityLivingBase entity, Ability ability, int oldState, int newState) {
super(entity, ability, null);
this.oldState = oldState;
this.newState = newState;
}
@@ -244,17 +246,13 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
}
}
/**
* Fired every 10 ticks for each active toggle ability.
* Scripts can set enabled to false to force-deactivate.
*/
public static class ToggleUpdateEvent extends AbilityEvent implements IAbilityEvent.ToggleUpdateEvent {
private final int tick;
private final int state;
private boolean enabled = true;
public ToggleUpdateEvent(ICustomNpc npc, Ability ability, int tick, int state) {
super(npc, ability, null);
public ToggleUpdateEvent(EntityLivingBase entity, Ability ability, int tick, int state) {
super(entity, ability, null);
this.tick = tick;
this.state = state;
}
@@ -281,7 +279,7 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
@Override
public String getHookName() {
return EnumScriptType.ABILITY_TOGGLE_UPDATE.function;
return EnumScriptType.ABILITY_TOGGLE_TICK.function;
}
}
}