mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 19:15:11 +00:00
Abilities are now Stored by Name not UUID. Refactor Built In and Toggleable Abilities
This commit is contained in:
1 parent
f39d843c70
commit
6514b217b9
12 files changed
+465
-127
No files matched your search
@@ -263,6 +263,9 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
return;
|
||||
}
|
||||
|
||||
// Tick active toggles (independent of currentAbility)
|
||||
tickActiveToggles();
|
||||
|
||||
if (currentAbility != null && currentAbility.isExecuting()) {
|
||||
tickCurrentAbility();
|
||||
|
||||
@@ -385,6 +388,11 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onToggleStateChanged(String key, boolean active) {
|
||||
syncToClient();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// SELECTION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -750,6 +758,13 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
compound.setTag("PlayerAbilities", list);
|
||||
compound.setInteger("PlayerAbilitySelected", selectedIndex);
|
||||
compound.setBoolean("AbilityAnimating", playingAbilityAnimation);
|
||||
|
||||
// Active toggles
|
||||
NBTTagList toggleList = new NBTTagList();
|
||||
for (String key : activeToggles.keySet()) {
|
||||
toggleList.appendTag(new NBTTagString(key));
|
||||
}
|
||||
compound.setTag("ActiveToggles", toggleList);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
@@ -772,6 +787,16 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
selectedIndex = Math.max(0, unlockedAbilities.size() - 1);
|
||||
}
|
||||
playingAbilityAnimation = compound.getBoolean("AbilityAnimating");
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user