Skip to content

Commit dc9e819

Browse files
committed
enhance kubejs documentation for ModifyGeneRequirementsEvent and update example code
1 parent 7912562 commit dc9e819

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

docs/geneticsresequenced/devs/kubejs.mdx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ NativeEvents.onEvent("dev.aaronhowser.mods.geneticsresequenced.event.custom.Modi
6161

6262
### [ModifyGeneRequirementsEvent](https://github.com/Berry-Club/Genetics-Resequenced/blob/NeoForge-1.21/src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/event/custom/ModifyGeneRequirementsEvent.kt)
6363

64+
This event is fired when the mod checks if an entity can have a specific Gene. This usually only happens when the entity's Genes change.
65+
66+
ModifyGeneRequirementsEvent has the following properties:
67+
- `gene` - The ResourceKey\<Gene> being checked
68+
- `requirements` - A MutableSet\<ResourceKey\<Gene>> representing the Genes required to have the checked Gene
69+
6470
```js
6571
NativeEvents.onEvent("dev.aaronhowser.mods.geneticsresequenced.event.custom.ModifyGeneRequirementsEvent", (event) => {
66-
let cringe = toGeneRk("geneticsresequenced:cringe");
67-
let cursed = toGeneRk("geneticsresequenced:cursed");
68-
69-
if (event.gene == cringe) {
70-
event.requirements.add(cursed)
72+
if (event.gene == "geneticsresequenced:cringe") {
73+
event.requirements.add("geneticsresequenced:cursed")
7174
}
7275
})
7376
```
@@ -77,9 +80,11 @@ NativeEvents.onEvent("dev.aaronhowser.mods.geneticsresequenced.event.custom.Modi
7780
```js
7881
const $GenesData = Java.loadClass('dev.aaronhowser.mods.geneticsresequenced.attachment.GenesData')
7982

80-
$GenesData.addGene(livingEntity, toGeneRk("geneticsresequenced:chatterbox"))
81-
$GenesData.removeGene(livingEntity, toGeneRk("geneticsresequenced:lay_egg"))
82-
let hasSlimyDeath = $GenesData.hasGene(livingEntity, toGeneRk("geneticsresequenced:slimy_death"))
83+
$GenesData.addGene(livingEntity, "geneticsresequenced:chatterbox")
84+
$GenesData.removeGene(livingEntity, "geneticsresequenced:lay_egg")
85+
let hasSlimyDeath = $GenesData.hasGene(livingEntity, "geneticsresequenced:slimy_death")
8386
```
8487

85-
This uses reflection to load the [GenesData](https://github.com/Berry-Club/Genetics-Resequenced/blob/NeoForge-1.21/src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/attachment/GenesData.kt) and [ModGenes](https://github.com/Berry-Club/Genetics-Resequenced/blob/NeoForge-1.21/src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/registry/ModGenes.kt) classes, allowing you to use their functions.
88+
This uses reflection to load the [GenesData](https://github.com/Berry-Club/Genetics-Resequenced/blob/NeoForge-1.21/src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/attachment/GenesData.kt) class, allowing you to use its functions.
89+
90+
(In Kotlin, a function that looks like `fun Example.doSomething(int: Int)` is actually compiled to `doSomething(Example, Int)` in Java)

0 commit comments

Comments
 (0)