mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 12:15:11 +00:00
IAbilityAction interface, AbilityAction unified slot, and bug fixes
- Added IAbilityAction interface (internal + API) for unified Ability/ChainedAbility handling - Created AbilityAction (replaces AbilitySlot) with 3 modes: INLINE_ABILITY, ABILITY_REFERENCE, CHAIN_REFERENCE - Unified DataAbilities storage from dual lists to single List<AbilityAction> - Added ChainedAbility, ChainedAbilityEntry, ChainedAbilityController - Updated PlayerAbilityData with resolveActionKey() for chain: prefix resolution - Added resolveAction/canResolveAction to AbilityController - Fixed unsafe cast in DataAbilities.onDamage() - Fixed NPE in GuiNPCAbilities for chain reference slots - Fixed NPC chain interrupt double cooldown - Fixed removeAbility() incorrectly removing chain references Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
1 parent
f39d843c70
commit
2f814c1903
17 files changed
+1482
-144
No files matched your search
@@ -0,0 +1,63 @@
|
||||
package kamkeel.npcs.controllers.data.ability;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* A single entry in a {@link ChainedAbility}, representing one ability
|
||||
* to execute in sequence along with its delay configuration.
|
||||
*/
|
||||
public class ChainedAbilityEntry {
|
||||
|
||||
/** Reference key (built-in name or custom ability name). */
|
||||
private String abilityReference = "";
|
||||
|
||||
/** Delay in ticks BEFORE this ability starts (after previous entry completes). */
|
||||
private int delayTicks = 0;
|
||||
|
||||
public ChainedAbilityEntry() {}
|
||||
|
||||
public ChainedAbilityEntry(String abilityReference, int delayTicks) {
|
||||
this.abilityReference = abilityReference != null ? abilityReference : "";
|
||||
this.delayTicks = Math.max(0, delayTicks);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// GETTERS / SETTERS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public String getAbilityReference() {
|
||||
return abilityReference;
|
||||
}
|
||||
|
||||
public void setAbilityReference(String abilityReference) {
|
||||
this.abilityReference = abilityReference != null ? abilityReference : "";
|
||||
}
|
||||
|
||||
public int getDelayTicks() {
|
||||
return delayTicks;
|
||||
}
|
||||
|
||||
public void setDelayTicks(int delayTicks) {
|
||||
this.delayTicks = Math.max(0, delayTicks);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// NBT
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("Reference", abilityReference);
|
||||
nbt.setInteger("Delay", delayTicks);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public static ChainedAbilityEntry fromNBT(NBTTagCompound nbt) {
|
||||
if (nbt == null) return null;
|
||||
|
||||
ChainedAbilityEntry entry = new ChainedAbilityEntry();
|
||||
entry.abilityReference = nbt.getString("Reference");
|
||||
entry.delayTicks = Math.max(0, nbt.getInteger("Delay"));
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user