mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 00:22:19 +00:00
Ability Effects
This commit is contained in:
1 parent
d6d29613e8
commit
563b6f7a26
26 files changed
+799
-324
No files matched your search
@@ -78,6 +78,9 @@ public abstract class Ability implements IAbility {
|
||||
// Custom data for external mods
|
||||
protected NBTTagCompound customData = new NBTTagCompound();
|
||||
|
||||
// Configurable potion effects
|
||||
protected List<AbilityEffect> effects = new ArrayList<>();
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// EXECUTION STATE (not saved, reset each combat)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -224,6 +227,21 @@ public abstract class Ability implements IAbility {
|
||||
hitEntity.velocityChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all configured effects to the given entity.
|
||||
* Call this after damage is applied to the target.
|
||||
*
|
||||
* @param entity The entity to apply effects to
|
||||
*/
|
||||
protected void applyEffects(EntityLivingBase entity) {
|
||||
if (entity == null || effects.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (AbilityEffect effect : effects) {
|
||||
effect.apply(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public float getTelegraphRadius() {
|
||||
return 5.0f;
|
||||
}
|
||||
@@ -662,6 +680,13 @@ public abstract class Ability implements IAbility {
|
||||
for (Condition c : conditions) condList.appendTag(c.writeNBT());
|
||||
nbt.setTag("conditions", condList);
|
||||
|
||||
// Effects
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
for (AbilityEffect effect : effects) {
|
||||
effectList.appendTag(effect.writeNBT());
|
||||
}
|
||||
nbt.setTag("effects", effectList);
|
||||
|
||||
// Type-specific
|
||||
NBTTagCompound typeNBT = new NBTTagCompound();
|
||||
writeTypeNBT(typeNBT);
|
||||
@@ -735,6 +760,18 @@ public abstract class Ability implements IAbility {
|
||||
if (c != null) conditions.add(c);
|
||||
}
|
||||
|
||||
// Effects
|
||||
effects.clear();
|
||||
if (nbt.hasKey("effects")) {
|
||||
NBTTagList effectList = nbt.getTagList("effects", 10);
|
||||
for (int i = 0; i < effectList.tagCount(); i++) {
|
||||
AbilityEffect effect = AbilityEffect.fromNBT(effectList.getCompoundTagAt(i));
|
||||
if (effect != null && effect.isValid()) {
|
||||
effects.add(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readTypeNBT(nbt.getCompoundTag("typeData"));
|
||||
}
|
||||
|
||||
@@ -807,7 +844,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setCooldownTicks(int cooldownTicks) {
|
||||
this.cooldownTicks = cooldownTicks;
|
||||
this.cooldownTicks = Math.max(0, cooldownTicks);
|
||||
}
|
||||
|
||||
public int getWindUpTicks() {
|
||||
@@ -815,7 +852,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setWindUpTicks(int windUpTicks) {
|
||||
this.windUpTicks = windUpTicks;
|
||||
this.windUpTicks = Math.max(0, windUpTicks);
|
||||
}
|
||||
|
||||
public int getActiveTicks() {
|
||||
@@ -823,7 +860,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setActiveTicks(int activeTicks) {
|
||||
this.activeTicks = activeTicks;
|
||||
this.activeTicks = Math.max(1, activeTicks);
|
||||
}
|
||||
|
||||
public int getRecoveryTicks() {
|
||||
@@ -831,7 +868,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setRecoveryTicks(int recoveryTicks) {
|
||||
this.recoveryTicks = recoveryTicks;
|
||||
this.recoveryTicks = Math.max(0, recoveryTicks);
|
||||
}
|
||||
|
||||
public boolean isInterruptible() {
|
||||
@@ -963,6 +1000,24 @@ public abstract class Ability implements IAbility {
|
||||
conditions.add(c);
|
||||
}
|
||||
|
||||
public List<AbilityEffect> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
public void setEffects(List<AbilityEffect> effects) {
|
||||
this.effects = effects != null ? effects : new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addEffect(AbilityEffect effect) {
|
||||
if (effect != null && effect.isValid()) {
|
||||
effects.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearEffects() {
|
||||
effects.clear();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// IAbility API METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in new issue
Block a user