---
title: 自定义基因
---

基因由数据定义，你可以通过数据包中的json文件创建自定义基因。

基因定义json文件放置在`/data/namespace/geneticsresequenced/gene/`目录下。例如，文件`/data/coolmodpack/geneticsresequenced/gene/example.json` 将创建一个id为`coolmodpack:example` 的基因。

基因的翻译键是动态生成的，遵循`gene.namespace.path`的模式。对于上述示例，翻译键为`gene.coolmodpack.example`。

基因的EMI信息配方也是动态生成的！与上述模式完全相同，只是在前面加上`info.`。例如`info.gene.coolmodpack.example`。

## json格式

基因定义文件中的每个字段都是可选的，因此`{}`是完全有效的json。事实上，多个默认基因已经在使用这种空定义了！

可用字段如下：

- `dna_points_required` —整数，默认`1`。填充一个质粒所需的DNA点数
- `requires_genes` —基因ID列表，默认`[]`。如果实体不拥有列表中的所有基因，该基因将消退
- `allowed_entities` —实体类型过滤器，默认`{"type": "neoforge:any"}`。也可以直接使用单个实体类型ID（`minecraft:pig`），或实体类型ID列表（`["minecraft:cow","minecraft:player"]`）。不在列表中的实体无法拥有该基因
- `potion_details` —对象列表，包含`effect`（药水效果ID）、`level`（药水等级，可选，默认1）、`duration`（效果持续的tick数，可选，默认-1无限）
- `attribute_modifiers` —对象列表，包含`attribute`（实体属性ID）、`modifier` 对象（含 `id`、`operation` 和 `amount`）
- `scares_entities_with_tag` —实体类型标签，默认无。拥有此标签的实体会逃离拥有该基因的实体
- `incompatible_genes` —基因ID列表，默认`[]`。如果实体已拥有列表中的任何基因，该基因将不会被添加