Better Ability Data Syncing

This commit is contained in:
Kam committed 2026-02-23 21:46:23 -05:00
1 parent a724f7f12c
commit 670b811e03
5 files changed
+93 -27

No files matched your search

@@ -12,6 +12,9 @@ import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumSyncAction;
import kamkeel.npcs.network.enums.EnumSyncType;
import kamkeel.npcs.network.packets.data.LoginPacket;
import kamkeel.npcs.network.packets.data.ability.AbilityCooldownSyncPacket;
import kamkeel.npcs.network.packets.data.ability.AbilityHotbarSyncPacket;
import kamkeel.npcs.network.packets.data.ability.PlayerAbilitySyncPacket;
import kamkeel.npcs.network.packets.data.large.SyncEffectPacket;
import kamkeel.npcs.network.packets.data.large.SyncPacket;
import kamkeel.npcs.network.packets.request.party.PartyInfoPacket;
@@ -865,6 +868,32 @@ public class SyncController {
PacketHandler.Instance.sendToPlayer(new SyncEffectPacket(compound), playerMP);
}
/**
* Full sync of all player ability state to the client: unlocked abilities,
* selection, toggles, hotbar layout, and cooldowns.
* Used for entity reconstruction and other full-refresh scenarios.
*/
public static void syncAbilities(EntityPlayerMP playerMP) {
PlayerData playerData = PlayerData.get(playerMP);
if (playerData == null) return;
PlayerAbilitySyncPacket.sendToPlayer(playerMP);
AbilityHotbarSyncPacket.sendToPlayer(playerMP);
AbilityCooldownSyncPacket.sendToPlayer(playerMP);
}
/**
* Lightweight sync of cooldown state only (global + per-ability).
* Called periodically (every 10 ticks) to keep the client's cooldown
* display accurate. Cooldowns are transient and not part of NBT sync.
*/
public static void syncAbilityCooldowns(EntityPlayerMP playerMP) {
PlayerData playerData = PlayerData.get(playerMP);
if (playerData == null) return;
AbilityCooldownSyncPacket.sendToPlayer(playerMP);
}
@SideOnly(Side.CLIENT)
public static void clientSyncEffects(NBTTagCompound compound) {
PlayerData playerData = PlayerData.get(Minecraft.getMinecraft().thePlayer);