File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
src/main/kotlin/dev/aaronhowser/mods/geneticsresequenced Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 77 - `getGene()` gets the ResourceKey of the Gene whose requirements are being modified
88 - `getRequirements()` gets the set of ResourceKeys of Genes that are required
99 - Add or remove from this set to change the requirements
10+ - ModifyEntityGenesEvent
11+ - Can be accessed via KubeJS
12+ - `getEntityType()` gets the ResourceKey of the EntityType whose gene weights are being modified
13+ - `getGeneWeights()` gets the map of ResourceKeys of Genes to their weights
14+ - Modify this map to change the gene weights
15+ - After this event fires, if the map is empty, it is set to have the Basic Gene with weight 1
1016
1117### Changed
1218
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dev.aaronhowser.mods.geneticsresequenced.data
33import com.mojang.serialization.Codec
44import com.mojang.serialization.codecs.RecordCodecBuilder
55import dev.aaronhowser.mods.geneticsresequenced.GeneticsResequenced
6+ import dev.aaronhowser.mods.geneticsresequenced.event.custom.ModifyEntityGenesEvent
67import dev.aaronhowser.mods.geneticsresequenced.gene.Gene
78import dev.aaronhowser.mods.geneticsresequenced.registry.ModGenes
89import dev.aaronhowser.mods.geneticsresequenced.registry.ModGenes.getHolderOrThrow
@@ -14,6 +15,7 @@ import net.minecraft.core.registries.Registries
1415import net.minecraft.resources.ResourceKey
1516import net.minecraft.resources.ResourceLocation
1617import net.minecraft.world.entity.EntityType
18+ import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS
1719import kotlin.jvm.optionals.getOrNull
1820
1921data class EntityGenes (
@@ -72,6 +74,9 @@ data class EntityGenes(
7274 result[geneHolder] = weight
7375 }
7476
77+ val event = ModifyEntityGenesEvent (entityRk, resultRks)
78+ FORGE_BUS .post(event)
79+
7580 if (result.isEmpty()) {
7681 val basic = ModGenes .BASIC .getHolderOrThrow(registries)
7782 result[basic] = 1
Original file line number Diff line number Diff line change 1+ package dev.aaronhowser.mods.geneticsresequenced.event.custom
2+
3+ import dev.aaronhowser.mods.geneticsresequenced.gene.Gene
4+ import net.minecraft.resources.ResourceKey
5+ import net.minecraft.world.entity.EntityType
6+ import net.neoforged.bus.api.Event
7+
8+ data class ModifyEntityGenesEvent (
9+ val entityType : ResourceKey <EntityType <* >>,
10+ val geneWeights : MutableMap <ResourceKey <Gene >, Int >
11+ ) : Event()
You can’t perform that action at this time.
0 commit comments