From 76fb9ee52fdf194d2102967ab246ac1f83eb5f53 Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 27 Jan 2026 14:46:17 -0500 Subject: [PATCH] Fix Dazed Ticks and other smaller issues --- .../data/ability/type/AbilityDash.java | 14 +++---- .../data/ability/type/AbilityGuard.java | 6 +-- .../data/ability/type/AbilityHeal.java | 27 ++++++------- .../data/ability/type/AbilityTeleport.java | 5 ++- .../data/ability/type/AbilityVortex.java | 39 +++++++++---------- .../assets/customnpcs/lang/en_US.lang | 3 +- 6 files changed, 44 insertions(+), 50 deletions(-) diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java index 586e402a8..cd4d42ac7 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java @@ -199,8 +199,6 @@ public class AbilityDash extends Ability { npc.motionX = 0; npc.motionZ = 0; npc.velocityChanged = true; - dashDirection = null; - chosenDirection = null; } @Override @@ -208,23 +206,21 @@ public class AbilityDash extends Ability { npc.motionX = 0; npc.motionZ = 0; npc.velocityChanged = true; + } + + @Override + public void cleanup() { dashDirection = null; chosenDirection = null; } private boolean isDashBlocked(EntityNPCInterface npc) { + if (dashDirection == null) return true; double nextX = dashDirection.xCoord * dashSpeed; double nextZ = dashDirection.zCoord * dashSpeed; return !npc.worldObj.getCollidingBoundingBoxes(npc, npc.boundingBox.copy().offset(nextX, 0, nextZ)).isEmpty(); } - @Override - public void reset() { - super.reset(); - dashDirection = null; - chosenDirection = null; - } - @Override public float getTelegraphRadius() { return 0; // No telegraph for dash diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java index 831ef97fd..fd9f25a24 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java @@ -116,11 +116,7 @@ public class AbilityGuard extends Ability { lastAttacker = attacker; lastDamageTaken = damage; counterTriggered = true; - - if (interruptible) { - performCounter(npc, npc.worldObj); - npc.abilities.interruptCurrentAbility(source, damage); - } + // Counter will be performed in onActiveTick - don't self-interrupt } private void performCounter(EntityNPCInterface npc, World world) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java index 59ef4751a..f19a7cb02 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java @@ -34,7 +34,14 @@ public class AbilityHeal extends Ability { private boolean instantHeal = true; // Runtime state - private transient List healedAllies = new ArrayList<>(); + private transient List healedAllies; + + private List getHealedAllies() { + if (healedAllies == null) { + healedAllies = new ArrayList<>(); + } + return healedAllies; + } public AbilityHeal() { this.typeId = "ability.cnpc.heal"; @@ -73,7 +80,7 @@ public class AbilityHeal extends Ability { public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) { if (world.isRemote) return; - healedAllies.clear(); + getHealedAllies().clear(); // Always find allies if we're healing them (needed for both instant and HoT) if (healAllies && healRadius > 0) { @@ -87,7 +94,7 @@ public class AbilityHeal extends Ability { spawnHealParticles(world, npc); } - for (EntityLivingBase ally : healedAllies) { + for (EntityLivingBase ally : getHealedAllies()) { healEntity(ally); spawnHealParticles(world, ally); } @@ -120,7 +127,7 @@ public class AbilityHeal extends Ability { } if (healAllies && healRadius > 0) { - for (EntityLivingBase ally : healedAllies) { + for (EntityLivingBase ally : getHealedAllies()) { if (!ally.isDead) { float allyTickHeal = tickHeal; // Add percentage-based heal portion for each ally @@ -164,7 +171,7 @@ public class AbilityHeal extends Ability { if (living instanceof EntityNPCInterface) { float dist = npc.getDistanceToEntity(living); if (dist <= healRadius) { - healedAllies.add(living); + getHealedAllies().add(living); } } } @@ -192,14 +199,8 @@ public class AbilityHeal extends Ability { } @Override - public void onInterrupt(EntityNPCInterface npc, net.minecraft.util.DamageSource source, float damage) { - healedAllies.clear(); - } - - @Override - public void reset() { - super.reset(); - healedAllies.clear(); + public void cleanup() { + getHealedAllies().clear(); } @Override diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java index 668b2f04d..218432fc9 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java @@ -374,7 +374,10 @@ public class AbilityTeleport extends Ability { double dist = Math.sqrt(Math.pow(living.posX - x, 2) + Math.pow(living.posZ - z, 2)); if (dist <= damageRadius) { // Apply damage with scripted event support (no knockback for teleport damage) - applyAbilityDamage(npc, living, damage, 0); + boolean wasHit = applyAbilityDamage(npc, living, damage, 0); + if (wasHit) { + applyEffects(living); + } } } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java index 70c1c96b7..fef61779e 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java @@ -8,7 +8,6 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex; @@ -36,10 +35,17 @@ public class AbilityVortex extends Ability { private float pullDamage = 0.0f; // Runtime state - private transient Set pulledEntities = new HashSet<>(); + private transient Set pulledEntities; private transient boolean pullComplete = false; private transient int ticksSincePullDamage = 0; + private Set getPulledEntities() { + if (pulledEntities == null) { + pulledEntities = new HashSet<>(); + } + return pulledEntities; + } + public AbilityVortex() { this.typeId = "ability.cnpc.vortex"; this.name = "Vortex"; @@ -82,7 +88,7 @@ public class AbilityVortex extends Ability { @Override public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) { - pulledEntities.clear(); + getPulledEntities().clear(); pullComplete = false; ticksSincePullDamage = 0; @@ -98,7 +104,7 @@ public class AbilityVortex extends Ability { double dist = npc.getDistanceToEntity(entity); if (dist <= pullRadius) { - pulledEntities.add(entity.getUniqueID()); + getPulledEntities().add(entity.getUniqueID()); count++; if (count >= maxTargets) break; } @@ -108,7 +114,7 @@ public class AbilityVortex extends Ability { if (target != null && !target.isDead) { double dist = npc.getDistanceToEntity(target); if (dist <= pullRadius) { - pulledEntities.add(target.getUniqueID()); + getPulledEntities().add(target.getUniqueID()); } } } @@ -116,7 +122,7 @@ public class AbilityVortex extends Ability { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - if (pullComplete || pulledEntities.isEmpty()) { + if (pullComplete || getPulledEntities().isEmpty()) { signalCompletion(); return; } @@ -128,10 +134,10 @@ public class AbilityVortex extends Ability { boolean anyStillPulling = false; ticksSincePullDamage++; - for (UUID uuid : new HashSet<>(pulledEntities)) { + for (UUID uuid : new HashSet<>(getPulledEntities())) { EntityLivingBase entity = findEntity(npc, world, uuid); if (entity == null || entity.isDead) { - pulledEntities.remove(uuid); + getPulledEntities().remove(uuid); continue; } @@ -141,7 +147,7 @@ public class AbilityVortex extends Ability { double dist = Math.sqrt(dx * dx + dy * dy + dz * dz); if (dist <= 1.0f) { - pulledEntities.remove(uuid); + getPulledEntities().remove(uuid); onTargetArrived(npc, entity, world); continue; } @@ -155,7 +161,7 @@ public class AbilityVortex extends Ability { AxisAlignedBB nextBox = entity.boundingBox.copy().offset(nextX, nextY, nextZ); if (!world.getCollidingBoundingBoxes(entity, nextBox).isEmpty()) { - pulledEntities.remove(uuid); + getPulledEntities().remove(uuid); continue; } @@ -171,7 +177,7 @@ public class AbilityVortex extends Ability { } } - if (!anyStillPulling && pulledEntities.isEmpty()) { + if (!anyStillPulling && getPulledEntities().isEmpty()) { pullComplete = true; signalCompletion(); } @@ -206,15 +212,8 @@ public class AbilityVortex extends Ability { } @Override - public void onComplete(EntityNPCInterface npc, EntityLivingBase target) { - pulledEntities.clear(); - pullComplete = false; - ticksSincePullDamage = 0; - } - - @Override - public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) { - pulledEntities.clear(); + public void cleanup() { + getPulledEntities().clear(); pullComplete = false; ticksSincePullDamage = 0; } diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 01e3ae541..8ac2d99c0 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1512,8 +1512,7 @@ ability.maxRange=Max Range ability.timing=Timing (ticks) ability.cooldown=Cooldown ability.windup=Wind Up -ability.active=Active -ability.recovery=Recovery +ability.dazed=Dazed Ticks ability.interruptible=Interruptible ability.threshold=Threshold ability.lockMove=Lock Move