Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
Kam committed 2026-02-12 20:33:44 -05:00
commit 105d274955
97 files changed
+8850 -6462

No files matched your search

@@ -4,6 +4,7 @@ import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.UserType;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.packets.data.telegraph.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
@@ -118,9 +119,8 @@ public class PlayerAbilityData implements IPlayerAbilityData {
case ACTIVE:
if (phaseChanged && oldPhase == AbilityPhase.WINDUP) {
// Just entered ACTIVE phase
TelegraphInstance telegraph = currentAbility.getTelegraphInstance();
if (telegraph != null) {
// Just entered ACTIVE phase - lock all telegraph positions
for (TelegraphInstance telegraph : currentAbility.getTelegraphInstances()) {
telegraph.lockPosition();
}
removeTelegraph(currentAbility, player);
@@ -418,6 +418,53 @@ public class PlayerAbilityData implements IPlayerAbilityData {
}
}
/**
* Handle damage taken while an ability is executing.
* Called from LivingHurtEvent BEFORE damage is applied to health.
* Triggers Guard counter detection and handles ability interruption.
*
* @param source The damage source
* @param amount The damage amount (post-armor)
* @return The modified damage amount (reduced by guard, or 0 if counter absorbs)
*/
public float onDamage(DamageSource source, float amount) {
if (currentAbility == null || !currentAbility.isExecuting()) {
return amount;
}
net.minecraft.entity.Entity sourceEntity = source.getEntity();
EntityLivingBase attacker = sourceEntity instanceof EntityLivingBase ? (EntityLivingBase) sourceEntity : null;
// Track counter state before calling onDamageTaken
boolean wasCounterTriggered = false;
if (currentAbility instanceof AbilityGuard) {
wasCounterTriggered = ((AbilityGuard) currentAbility).isCounterTriggered();
}
currentAbility.onDamageTaken(playerData.player, attacker, source, amount);
// Guard: handle damage reduction and counter absorption
if (currentAbility instanceof AbilityGuard) {
AbilityGuard guard = (AbilityGuard) currentAbility;
if (guard.isGuarding()) {
// Counter just triggered — absorb full damage
if (!wasCounterTriggered && guard.isCounterTriggered()) {
return 0;
}
// Normal guard — apply flat damage reduction
float reduction = guard.getDamageReductionFactor();
return Math.max(0, amount - reduction);
}
}
// Check for ability interruption
if (currentAbility != null && currentAbility.canInterrupt(source)) {
interruptCurrentAbility();
}
return amount;
}
@Override
public boolean isOnCooldown() {
EntityPlayer player = playerData.player;
@@ -451,23 +498,25 @@ public class PlayerAbilityData implements IPlayerAbilityData {
// ═══════════════════════════════════════════════════════════════════
private void spawnTelegraph(Ability ability, EntityPlayer player, EntityLivingBase target) {
TelegraphInstance telegraph = ability.createTelegraph(player, target);
if (telegraph != null) {
ability.setTelegraphInstance(telegraph);
List<TelegraphInstance> telegraphs = ability.createTelegraphs(player, target);
if (!telegraphs.isEmpty()) {
ability.setTelegraphInstances(telegraphs);
if (player instanceof EntityPlayerMP) {
TelegraphSpawnPacket.sendToTracking(telegraph, player);
for (TelegraphInstance telegraph : telegraphs) {
TelegraphSpawnPacket.sendToTracking(telegraph, player);
}
}
}
}
private void removeTelegraph(Ability ability, EntityPlayer player) {
TelegraphInstance telegraph = ability.getTelegraphInstance();
if (telegraph != null) {
List<TelegraphInstance> telegraphs = ability.getTelegraphInstances();
for (TelegraphInstance telegraph : telegraphs) {
if (player instanceof EntityPlayerMP) {
TelegraphRemovePacket.sendToTracking(telegraph.getInstanceId(), player);
}
ability.setTelegraphInstance(null);
}
ability.setTelegraphInstances(null);
}
// ═══════════════════════════════════════════════════════════════════