Fix Dazed Ticks and other smaller issues

This commit is contained in:
Kam committed 2026-01-27 14:46:17 -05:00
1 parent 4330405f96
commit 76fb9ee52f
6 files changed
+44 -50

No files matched your search

@@ -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
@@ -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) {
@@ -34,7 +34,14 @@ public class AbilityHeal extends Ability {
private boolean instantHeal = true;
// Runtime state
private transient List<EntityLivingBase> healedAllies = new ArrayList<>();
private transient List<EntityLivingBase> healedAllies;
private List<EntityLivingBase> 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
@@ -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);
}
}
}
}
@@ -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<UUID> pulledEntities = new HashSet<>();
private transient Set<UUID> pulledEntities;
private transient boolean pullComplete = false;
private transient int ticksSincePullDamage = 0;
private Set<UUID> 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;
}