ForgeEvents.onEvent("net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent", event => {
    let mark = event.entity
    // 处理登记盔甲架的装备同步
    if (mark.persistentData.getString("Resident")) {
        let soldierUuid = mark.persistentData.getString("Resident")
        if (soldierUuid) {
            // 首先尝试直接通过UUID获取士兵实体
            let soldier = mark.level.getEntity(soldierUuid)
            if (soldier) {
                // 如果直接获取成功，立即同步装备
                global.weaponUtils.syncEquipment(mark, soldier)
            } else {
                // 获取失败，从盔甲架Owner信息获取玩家
                let ownerUuid = mark.persistentData.getString("Owner")
                if (ownerUuid) {
                    let ownerPlayer = mark.level.server.getPlayer(ownerUuid)
                    if (ownerPlayer) {
                        // 使用全局方法获取士兵实体
                        global.GetGlobalEntity(soldierUuid, ownerPlayer, (soldier, usedForceLoad) => {
                            if (soldier) {
                                // 使用全局方法同步装备
                                global.weaponUtils.syncEquipment(mark, soldier)
                            }
                        })
                    } 
                } 
            }
        }
    }
})