// Path: src/main/java/com/legobmw99/stormlight/api/ISurgebindingData.java
// public interface ISurgebindingData {
// 
//     @Nullable
//     Order getOrder();
// 
//     void setOrder(Order order);
// 
//     Ideal getIdeal();
// 
//     void setIdeal(Ideal ideal);
// 
//     void storeBlade(@Nonnull ItemStack blade);
// 
// 
//     boolean isBladeStored();
// 
//     boolean addBladeToInventory(Player player);
// 
//     UUID getSprenID();
// 
//     void setSprenID(UUID sprenID);
// 
// 
//     default boolean isKnight() {
//         return getOrder() != null && getIdeal() != Ideal.UNINVESTED && getIdeal() != Ideal.TRAITOR;
//     }
// 
//     default Ideal progressIdeal() {
//         Ideal next = getIdeal().progressIdeal();
//         setIdeal(next);
//         return next;
//     }
// 
//     default Ideal regressIdeal() {
//         Ideal next = getIdeal().regressIdeal();
//         setIdeal(next);
//         return next;
//     }
// 
//     default boolean earnedBlade() {
//         Order order = getOrder();
//         return order != null && order.getBladeIdeal().compareTo(getIdeal()) < 0;
//     }
// 
//     default boolean canUseSurge(Surge surge) {
//         Order order = getOrder();
//         Ideal ideal = getIdeal();
//         return order != null &&
//                ((surge == order.getFirst() && order.getFirstIdeal().compareTo(ideal) < 0) || (surge == order.getSecond() && order.getSecondIdeal().compareTo(ideal) < 0));
//     }
// 
//     void load(CompoundTag nbt);
// 
//     CompoundTag save();
// }
// 
// Path: src/main/java/com/legobmw99/stormlight/modules/powers/data/SurgebindingCapability.java
// public class SurgebindingCapability {
// 
//     public static final Capability<ISurgebindingData> PLAYER_CAP = CapabilityManager.get(new CapabilityToken<>() {
//     });
// 
//     public static final ResourceLocation IDENTIFIER = new ResourceLocation(Stormlight.MODID, "surgebinding_data");
// 
// 
//     public static void registerCapability(final RegisterCapabilitiesEvent event) {
//         event.register(ISurgebindingData.class);
//     }
// 
// }


import com.legobmw99.stormlight.api.ISurgebindingData;
import com.legobmw99.stormlight.modules.powers.data.SurgebindingCapability;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.network.NetworkEvent;
import java.util.UUID;
import java.util.function.Supplier;
package com.legobmw99.stormlight.network.packets;




public class SurgebindingDataPacket {

    private final CompoundTag nbt;
    private final UUID uuid;


    public SurgebindingDataPacket(ISurgebindingData data, Player player) {
        this.uuid = player.getUUID();
        this.nbt = (data != null) ? data.save() : new CompoundTag();

    }

    private SurgebindingDataPacket(CompoundTag data, UUID uuid) {
        this.nbt = data;
        this.uuid = uuid;
    }

    public static SurgebindingDataPacket decode(FriendlyByteBuf buf) {
        return new SurgebindingDataPacket(buf.readNbt(), buf.readUUID());
    }

    public void encode(FriendlyByteBuf buf) {
        buf.writeNbt(this.nbt);
        buf.writeUUID(this.uuid);
    }

    public void handle(Supplier<NetworkEvent.Context> ctx) {
        ctx.get().enqueueWork(() -> {
            Player player = Minecraft.getInstance().level.getPlayerByUUID(this.uuid);
// Path: src/main/java/com/legobmw99/stormlight/api/ISurgebindingData.java
// public interface ISurgebindingData {
// 
//     @Nullable
//     Order getOrder();
// 
//     void setOrder(Order order);
// 
//     Ideal getIdeal();
// 
//     void setIdeal(Ideal ideal);
// 
//     void storeBlade(@Nonnull ItemStack blade);
// 
// 
//     boolean isBladeStored();
// 
//     boolean addBladeToInventory(Player player);
// 
//     UUID getSprenID();
// 
//     void setSprenID(UUID sprenID);
// 
// 
//     default boolean isKnight() {
//         return getOrder() != null && getIdeal() != Ideal.UNINVESTED && getIdeal() != Ideal.TRAITOR;
//     }
// 
//     default Ideal progressIdeal() {
//         Ideal next = getIdeal().progressIdeal();
//         setIdeal(next);
//         return next;
//     }
// 
//     default Ideal regressIdeal() {
//         Ideal next = getIdeal().regressIdeal();
//         setIdeal(next);
//         return next;
//     }
// 
//     default boolean earnedBlade() {
//         Order order = getOrder();
//         return order != null && order.getBladeIdeal().compareTo(getIdeal()) < 0;
//     }
// 
//     default boolean canUseSurge(Surge surge) {
//         Order order = getOrder();
//         Ideal ideal = getIdeal();
//         return order != null &&
//                ((surge == order.getFirst() && order.getFirstIdeal().compareTo(ideal) < 0) || (surge == order.getSecond() && order.getSecondIdeal().compareTo(ideal) < 0));
//     }
// 
//     void load(CompoundTag nbt);
// 
//     CompoundTag save();
// }
// 
// Path: src/main/java/com/legobmw99/stormlight/modules/powers/data/SurgebindingCapability.java
// public class SurgebindingCapability {
// 
//     public static final Capability<ISurgebindingData> PLAYER_CAP = CapabilityManager.get(new CapabilityToken<>() {
//     });
// 
//     public static final ResourceLocation IDENTIFIER = new ResourceLocation(Stormlight.MODID, "surgebinding_data");
// 
// 
//     public static void registerCapability(final RegisterCapabilitiesEvent event) {
//         event.register(ISurgebindingData.class);
//     }
// 
// }


// Path: src/main/java/com/legobmw99/stormlight/network/packets/SurgebindingDataPacket.java
import com.legobmw99.stormlight.api.ISurgebindingData;
import com.legobmw99.stormlight.modules.powers.data.SurgebindingCapability;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.network.NetworkEvent;
import java.util.UUID;
import java.util.function.Supplier;

package com.legobmw99.stormlight.network.packets;




public class SurgebindingDataPacket {

    private final CompoundTag nbt;
    private final UUID uuid;


    public SurgebindingDataPacket(ISurgebindingData data, Player player) {
        this.uuid = player.getUUID();
        this.nbt = (data != null) ? data.save() : new CompoundTag();

    }

    private SurgebindingDataPacket(CompoundTag data, UUID uuid) {
        this.nbt = data;
        this.uuid = uuid;
    }

    public static SurgebindingDataPacket decode(FriendlyByteBuf buf) {
        return new SurgebindingDataPacket(buf.readNbt(), buf.readUUID());
    }

    public void encode(FriendlyByteBuf buf) {
        buf.writeNbt(this.nbt);
        buf.writeUUID(this.uuid);
    }

    public void handle(Supplier<NetworkEvent.Context> ctx) {
        ctx.get().enqueueWork(() -> {
            Player player = Minecraft.getInstance().level.getPlayerByUUID(this.uuid);
            if (player != null && SurgebindingCapability.PLAYER_CAP != null) {