-
Notifications
You must be signed in to change notification settings - Fork 2
6. For Modpack Devs
Several features of the mod can be configured via datapacks! I recommend using KubeJS.
While the mod doesn't explicitly have KubeJS support, it's relatively simple to implement yourself!
const $GenesData = Java.loadClass('dev.aaronhowser.mods.geneticsresequenced.attachment.GenesData')
const $GeneRegistry = Java.loadClass('dev.aaronhowser.mods.geneticsresequenced.api.genes.GeneRegistry')
const addGene = (livingEntity, geneString) => {
const gene = $GeneRegistry.INSTANCE.fromString(geneString)
$GenesData.Companion.addGene(livingEntity, gene)
}
const removeGene = (livingEntity, geneString) => {
const gene = $GeneRegistry.INSTANCE.fromString(geneString)
$GenesData.Companion.removeGene(livingEntity, gene)
}
const hasGene = (livingEntity, geneString) => {
const gene = $GeneRegistry.INSTANCE.fromString(geneString)
return $GenesData.Companion.hasGene(livingEntity, gene)
}
PlayerEvents.chat(event => {
const player = event.player
const geneString = 'geneticsresequenced:chatterbox'
console.log(`[1] Has gene: ${hasGene(player, geneString)}`)
addGene(player, geneString)
console.log(`[2] Has gene: ${hasGene(player, geneString)}`)
removeGene(player, geneString)
console.log(`[3] Has gene: ${hasGene(player, geneString)}`)
})
After a player sends something in chat, this would give and then remove the Chatterbox Gene.
This uses reflection to load the GenesData and GeneRegistry classes, allowing you to use their functions.
The mod is written in Kotlin, which is why it has the weird notation with .Instance.
and .Companion.
.
As of 1.3.0, Genes are data-driven! That means you can very easily add custom Genes just by adding a json file in the correct location.
Gene definition jsons go in /data/______/geneticsresequenced/gene/
. /data/abcde/geneticsresequenced/gene/a_gene.json
would make the gene abcde:a_gene
.
A Gene's translation key is dynamically generated. It uses the pattern "gene.namespace.path"
. For the above example, the translation key would be gene.abcde.a_gene
.
The Gene's EMI Information recipe is also dynamically generated! It's the exact same as above, but with info.
at the start. For example, info.gene.abcde.a_gene
. EMI Information recipes can be seen from the DNA Helix's uses.
Every field in a Gene is optional, so {}
is a valid definition json. In fact, several default Genes use this! The possible fields are:
-
dna_points_required
- An integer.
- How many DNA Points are required to fill a Plasmid
- Defaults to 1
-
requires_genes
- A list of Gene ids
- The Gene will fade away if you don't have every Gene in the list
- Defaults to empty
-
allowed_entities
- An entity type filter, generally in the form of an entity id (
"minecraft:player"
) or a list of entities (["minecraft:cow", "minecraft:pig"]
, or[]
for no entities) - Only entity types in the list can have the Gene
- Defaults to
{"type": "neoforge:any"}
(that is, all entity types can have it)
- An entity type filter, generally in the form of an entity id (
-
potion_details
- An object with these fields, all but the first are optional:
-
effect
- A mob effect
-
level
- An integer
- The potion's level
- Defaults to 1
-
duration
- An integer
- The amount of ticks that the effect lasts for (unnecessary in almost all cases, since the effect is re-added every couple seconds, and removed if the Gene is removed)
- Defaults to -1, aka infinite
-
-
show_icon
- A boolean
- Defaults to false
- An object with these fields, all but the first are optional:
-
attribute_modifiers
- A list of objects with these fields:
-
attribute
- An entity attribute id (
"minecraft:generic.max_health")
- An entity attribute id (
-
modifier
- An object with these fields:
-
id
- A Resource Location
- Should be unique
-
operation
- One of the following:
"add_value"
,"add_multiplied_base"
,"add_multiplied_total"
- One of the following:
-
amount
- A number
- Modifies the attribute by the operation with this amount
-
- An object with these fields:
-
- A list of objects with these fields:
-
scares_entities_with_tag
- An entity type tag
- Entities with that tag run away from entities that have the Gene
- Defaults to nothing
You can modify any part of an existing Gene just by overriding the file with datapacks. For example, if you want to make geneticsresequenced:cringe
require more DNA Points, you would make a new /data/geneticsresequenced/geneticsresequenced/cringe.json
that has everything from the default file, but the new dna_points_required
value.
You can't unregister Genes, but you can mark them as disabled with a tag!
There are 4 built-in Gene tags:
-
#geneticsresequenced:hidden
- Removes it from the Plasmid list etc. Currently only
geneticsresequenced:basic
has this, as it's not really a Gene
- Removes it from the Plasmid list etc. Currently only
-
#geneticsresequenced:negative
- Marks it as negative, which makes it so that players can't have it by default (except for Cringe, which ignores this)
- Also colors the Gene name red
-
#geneticsresequenced:mutation
- Colors the Gene name purple (not really anything else)
-
#geneticsresequenced:disabled
- Stops the Gene from functioning, and removes it from the possible Genes list when decrypting Genes
You would change this with KubeJS like so:
ServerEvents.tags('geneticsresequenced:gene', event => {
// Disables the Keep Inventory Gene, in case of conflicts with grave style mods etc
event.add('geneticsresequenced:disabled', 'geneticsresequenced:keep_inventory')
})