> For the complete documentation index, see [llms.txt](https://ersha.gitbook.io/attributeplus-pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/descriptionlinecondition-1.md).

# EmbeddedCondition

## 跟 DescriptionRead 有什么区别呢?

> **DescriptionRead** 无法做到单独新增一个 **内嵌式条件** 必须同时覆写 read 与 condition 才能做到,这相当于需要完全重写一个读取组件\
> \
> 具体读取格式请查看 [**属性内嵌条件格式**](https://ersha.gitbook.io/attributeplus-pro/shu-xing-xiang-guan/du-qu-xiang-guan/shu-xing-du-qu-tiao-jian)

```kotlin
/**
 * 单行描述条件
 * 格式 "属性名: 值 / <条件>" 如果满足该行条件才会读取该行描述属性
 * 
 * 如何注册? : 使用 @AutoRegister 进行注册
 */
interface DescriptionLineCondition : DescriptionComponent {

    /**
     * [entity] 可为空需要自行判断
     * [text] 为 "<属性内容> / <条件>" 中的 <条件> 内容
     * 返回值为 true 时则读取属性,为 false 时则不读取
     */
    fun condition(entity: LivingEntity?, text: String): Boolean
    
    fun condition(entity: LivingEntity?, text: String, slot: EquipmentSlot?): Boolean{
        return this.condition(entity, lore)
    }
    
    fun condition(entity: LivingEntity?, text: String, slot: EquipmentSlot?, item: ItemStack?): Boolean {
        return this.condition(entity, lore, slot)
    }
}
```

## 示例

```kotlin
@AutoRegister
class LineCondition : DescriptionLineCondition {

    override fun condition(entity: LivingEntity?, lore: String): Boolean {
        if (entity == null){
            return true
        } else {
            if (entity is Player){
                if (lore.contains("等级要求-")) {
                    val value = lore.split("等级要求-")[1]
                    return entity.level >= value.toInt()
                }
            }
            return true
        }
    }
}
```

> 以上示例在实际使用中格式是 "物理伤害: 1000 **/** 等级要求-100"\
> 等级大于等于 100 时就会激活该行属性,增加 1000 点物理伤害\
> \
> 条件只能写在 **" / "** 右边


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ersha.gitbook.io/attributeplus-pro/kai-fa-wen-dang/descriptionlinecondition-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
