Abilities are now Stored by Name not UUID. Refactor Built In and Toggleable Abilities

This commit is contained in:
Kam committed 2026-02-17 23:08:12 -05:00
1 parent f39d843c70
commit 6514b217b9
12 files changed
+465 -127

No files matched your search

@@ -11,6 +11,7 @@ import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.entity.EntityNPCInterface;
@@ -297,6 +298,9 @@ public class DataAbilities extends AbstractDataAbilities {
if (positionLocked) releaseLockedPosition();
}
// Tick active toggles (independent of currentAbility)
tickActiveToggles();
// Tick current ability if executing (shared logic from base class)
if (currentAbility != null && currentAbility.isExecuting()) {
tickCurrentAbility();
@@ -664,6 +668,7 @@ public class DataAbilities extends AbstractDataAbilities {
*/
public void reset() {
stopCurrentAbility();
clearActiveToggles();
// Roll cooldown so NPC doesn't immediately attack after reset
rollCooldownOnReset();
@@ -983,6 +988,13 @@ public class DataAbilities extends AbstractDataAbilities {
}
compound.setTag("Abilities", abilityList);
// Active toggles
NBTTagList toggleList = new NBTTagList();
for (String key : activeToggles.keySet()) {
toggleList.appendTag(new NBTTagString(key));
}
compound.setTag("ActiveToggles", toggleList);
return compound;
}
@@ -1000,5 +1012,15 @@ public class DataAbilities extends AbstractDataAbilities {
abilitySlots.add(slot);
}
}
// Active toggles - restore state directly (no onToggleOn callback during load)
activeToggles.clear();
if (compound.hasKey("ActiveToggles")) {
NBTTagList toggleNbt = compound.getTagList("ActiveToggles", 8); // 8 = TAG_STRING
for (int i = 0; i < toggleNbt.tagCount(); i++) {
String key = toggleNbt.getStringTagAt(i);
setToggleEntryDirect(key, true);
}
}
}
}