Skip to content

Commit 60316ba

Browse files
committed
feat: add methods to add and remove genes using ResourceKey in LivingEntity
1 parent ccdc61d commit 60316ba

File tree

1 file changed

+11
-0
lines changed
  • src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/attachment

1 file changed

+11
-0
lines changed

src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/attachment/GenesData.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ data class GenesData(
130130
return true
131131
}
132132

133+
@JvmStatic
134+
fun LivingEntity.addGene(newGeneKey: ResourceKey<Gene>): Boolean {
135+
val holder = ModGenes.fromResourceKey(registryAccess(), newGeneKey) ?: return false
136+
return this.addGene(holder)
137+
}
133138

134139
@JvmStatic
135140
fun LivingEntity.removeGene(removedGeneHolder: Holder<Gene>): Boolean {
@@ -150,6 +155,12 @@ data class GenesData(
150155
return true
151156
}
152157

158+
@JvmStatic
159+
fun LivingEntity.removeGene(removedGeneKey: ResourceKey<Gene>): Boolean {
160+
val holder = ModGenes.fromResourceKey(registryAccess(), removedGeneKey) ?: return false
161+
return this.removeGene(holder)
162+
}
163+
153164
@JvmStatic
154165
@OptIn(ExperimentalContracts::class)
155166
fun Entity.hasPermanentGene(gene: Holder<Gene>): Boolean {

0 commit comments

Comments
 (0)