/givesample
基本信息
| 属性 | 值 |
|---|---|
| 指令名 | givesample(无 /gendustry 前缀) |
| 权限等级 | 2 |
| 注册时机 | FMLServerStartingEvent,Gendustry.scala:167 |
| 用法 | /givesample <species> <chromosome> <allele>(gendustry.givesample.usage) |
| 参数个数 | 恰好 3 |
| Tab 补全 | 3 级:物种根 UID → 染色体名 → 等位基因 UID(addTabCompletionOptions 三分支 match) |
功能
凭空发放一张指定等位基因的 Gene Sample,绕过 Genetic Sampler 的随机采样。这是精确构造基因的调试手段。
校验链(4 级)
| 顺序 | 校验 | 失败异常 | 消息键 |
|---|---|---|---|
| 1 | 参数个数 ≠ 3 | WrongUsageException |
gendustry.givesample.usage |
| 2 | rootUid 不在 validRoots |
CommandException |
gendustry.givesample.error.root(未知的品种: %s) |
| 3 | alleleUid 不在 validAlleles |
CommandException |
gendustry.givesample.error.allele(未知的基因: %s) |
| 4 | chromosomeName 不在 validChromosomes(root) |
CommandException |
gendustry.givesample.error.chromosome(未知的染色体: %s) |
| 5 | isValidAllele(root, chromosome, allele) 为假 |
CommandException |
gendustry.givesample.error.invalid(染色体对应了错误的基因) |
第 5 步是语义校验:该染色体属于哪个等位基因类(chr.getAlleleClass)必须能容纳请求的等位基因实例。例如向蜂种的「物种」染色体请求一个「行为」等位基因会被拒绝。
validRoots = alleleRegistry.getSpeciesRoot 的全部 key;validAlleles = alleleRegistry.getRegisteredAlleles 的全部 key。两者都是 lazy val,首次执行时快照。
参数格式
| 参数 | 含义 | 取值来源 |
|---|---|---|
<species> |
物种根 UID(不是物种 UID) | 如 rootBees、rootTrees、rootFlowers |
<chromosome> |
染色体枚举名的小写形式 | GeneticsHelper.getCleanKaryotype(root) 的键 c.toString.toLowerCase(Locale.US),如 species / color / lifespan |
<allele> |
等位基因 UID | 如 forestry.speciesDiligent、gendustry.color |
注意第二条是物种根 UID,与 /givetemplate 用的物种 UID(如 forestry.speciesDiligent)不是同一套标识符。
成功输出
GeneSample.newStack(GeneSampleInfo(root, chromosome, allele))
→ player.entityDropItem(sample, 0),delayBeforeCanPickup = 0
→ 回复 gendustry.givesample.success
简中消息为 基因样本 (品种=%s, 染色体=%s, 基因=%s) 已给玩家 %s(zh_CN.lang:219),英文为 Given sample (Species=%s, Chromosome=%s, Allele=%s) to %s。两条消息都完整翻译(5 个消息键在 en_US 与 zh_CN 中均存在)。
相关条目
- /givetemplate - 姊妹指令,产出模板
- /dumpalleles - 第三条指令
- Gene Sample - 发放的物品