File tree Expand file tree Collapse file tree 2 files changed +1
-30
lines changed
docs/geneticsresequenced/devs
src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/event/custom Expand file tree Collapse file tree 2 files changed +1
-30
lines changed Original file line number Diff line number Diff line change 44
55While the mod doesn't explicitly have KubeJS support, it's relatively simple to implement it yourself!
66
7- ### Some useful reflections
8-
9- Some methods may require a ResourceKey\< Gene>, so here's some methods to help with that:
10-
11- ``` js
12- const $ResourceKey = Java .loadClass (" net.minecraft.resources.ResourceKey" );
13- const $ResourceLocation = Java .loadClass (" net.minecraft.resources.ResourceLocation" );
14-
15- const GENE_REGISTRY_KEY = $ResourceKey .createRegistryKey ($ResourceLocation .fromNamespaceAndPath (" geneticsresequenced" , " gene" ));
16-
17- const toGeneRk = (geneString ) => {
18- const [namespace , path ] = geneString .split (" :" );
19- return $ResourceKey .create (GENE_REGISTRY_KEY , $ResourceLocation .fromNamespaceAndPath (namespace, path));
20- };
21- ```
22-
237### [ GeneChangeEvent] ( https://github.com/Berry-Club/Genetics-Resequenced/blob/NeoForge-1.21/src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced/event/custom/GeneChangeEvent.kt )
248
259``` js
@@ -54,7 +38,7 @@ There are also some useful methods on the event:
5438``` js
5539NativeEvents .onEvent (" dev.aaronhowser.mods.geneticsresequenced.event.custom.ModifyEntityGenesEvent" , (event ) => {
5640 if (event .entityTypeString == " minecraft:cow" ) {
57- event .setWeight (" geneticsresequenced:eat_grass " , 3 );
41+ event .setWeight (" geneticsresequenced:lay_egg " , 999 );
5842 event .remove (" geneticsresequenced:milky" );
5943 }
6044});
Original file line number Diff line number Diff line change @@ -17,12 +17,6 @@ data class ModifyEntityGenesEvent(
1717
1818 fun getWeight (gene : ResourceKey <Gene >): Int = geneWeights.getOrDefault(gene, 0 )
1919
20- fun getWeight (geneString : String ): Int {
21- val geneRl = ResourceLocation .parse(geneString)
22- val geneRk = ResourceKey .create(ModGenes .GENE_REGISTRY_KEY , geneRl)
23- return getWeight(geneRk)
24- }
25-
2620 fun setWeight (gene : ResourceKey <Gene >, weight : Int ) {
2721 if (weight <= 0 ) {
2822 geneWeights.remove(gene)
@@ -32,13 +26,6 @@ data class ModifyEntityGenesEvent(
3226 geneWeights[gene] = weight
3327 }
3428
35- fun setWeight (geneString : String , weight : Int ) {
36- val geneRl = ResourceLocation .parse(geneString)
37- val geneRk = ResourceKey .create(ModGenes .GENE_REGISTRY_KEY , geneRl)
38- setWeight(geneRk, weight)
39- }
40-
4129 fun remove (gene : ResourceKey <Gene >) = setWeight(gene, 0 )
42- fun remove (geneString : String ) = setWeight(geneString, 0 )
4330
4431}
You can’t perform that action at this time.
0 commit comments