developer-friendly domain specific language for data generator purpose
A DSL for data generator, makes your life better.
- Recipe DSL
- Loot Table DSL
- Advancement DSL
- NBT DSL
- Language DSL
Groovy gradle:
repositories {
maven { url url 'https://www.cursemaven.com' }
}
dependencies {
implementation fg.deobf('curse.maven:data-generator-dsl-473005:FILE_ID')
}
Kotlin gradle:
repositories {
maven(url = 'https://www.cursemaven.com')
}
dependencies {
implementation(project.the<DependencyManagementExtension>()
.deobf(project.dependencies.create('curse.maven:data-generator-dsl-473005:FILE_ID')))
}
Versions | File ID |
---|---|
1.0.0 | 3279767 |
recipe(resultItem, count) { // Count is set to 1 in default
pattern {
"""
xxx
xxx
xxx
"""
} // You don't need to trim string, mod will done for you.
key {
'x' to YourItem // Creates a key
} // You can add more keys if there are more.
group("") // Your Group here
criterion {
"has_dirt" to hasItem(AnotherItem) // Creates a Criterion
} // You can add more criterions if there are more.
}.build(conumer) // Remember to build
conditionalRecipe {
condition {
// Your Conditions here, examples in Condition part.
}
recipe {
recipe(resultItem, count) {
//...
}.build(this) // add your shaped recipe here, build it with `this` keyword instead of `it`
}
advancement(advancementID) {
// Your ConditionalAdvancement here, examples in ConditionalAdvancement part.
}
}.genAdvancement().build(consumer, recipeID) // You can discard genAdvancement()
// or
conditionalRecipe {
// ...
}.build(consumer) {
"minecraft" to "conditional" // Creates a ResourceLocation
}
// ... We take ConditionalRecipe as example
condition {
and {
not(modLoaded("minecraft")) +
modLoaded {
+"eki_lib"
+"eki"
} +
itemExists {
"minecraft" to "dirt" // Creates a ResourceLocation
}
}
}
// or
condition {
or {
modLoaded("ekinomy") +
True +
False
}
}
// or
condition {
False
}
// ...
// ... We take ConditionalRecipe as example
adavancement(conditionalAdavancementID) {
condition {
// Your Condition here
}
advancement { // Actual Advancement
// Your Advancement here, examples in Advancement part.
}
}
// ...
// ... We take ConditionalAdvancement as example
advancement {
parentID {
"minecraft" to "test" // Creates a ResourceLocation
}
parent {
parentAdvancement
}
/**
* You must provide either parentID or parent
*/
display(
// Construct your AdvancementBuilder.DisplayInfo here
)
}
// ...
lootTable {
parameterSet(paramSet) // Set a predefined loot parameter set
parameterSet { // Or create your own loot parameters here
optional(param1, param2) // Defines param1 and param2 as optional parameters, add more if you want
required(param3, param4) // Defines param3 and param4 as optional parameters, add more if you want
}
pool { // Create a loot pool with exactly 1 roll in default and empty name. You can change rolls with `pool(roll = yourRollNumber)`, same as changing loot pool name.
// See Loot Pool
}
/**
* Note: You can add pools with the following examples.
*/
pool(1, 9f) { // Loot pool with binomial range of rolls, beware of the number type you passed in.
}
pool(1f, 7f) { // Loot pool with random range of rolls, beware of the number type you passed in.
}
function {
// See Loot Functions
}
}
// ... We take Loot Table's pool as example
pool {
// You can add as many loot entries in a single pool
itemLoot(Items.STICK) // Create a item loot entry, you can pass item or block.
tagLoot(ItemTags.WOOL) // Create a tag loot entry
tableLoot(ResourceLocation("grass_block")) // Create a table loot entry
alternativesLoot { // Create a alternative loot entry
itemLoot(Items.ITEM_FRAME)
// ... Add more loot entries here
}
dynamicLoot(ShulkerBoxBlock.CONTENTS) // Create a dynamic loot entry
emptyLoot {
weight(2) // Optional
quality(2) // Optional
}
function {
// See Loot Functions
}
condition {
// See Loot Conditions
}
bonusRoll(1f, 7f) // Optional
}
// ...
This part is tricky since not every loot entry is same as others, so check out source code if you're not sure.
// ... We take Loot Pool's item loot entry as example
itemLoot(Items.STICK) {
function {
// See Loot Functions
}
condition {
// See Loot Conditions
}
weight(2) // Optional
quality(2) // Optional
}
// ...
Alternatives loot entry is kinda different from other loot entries, see below:
alternativeLoot {
condition {
// See Loot Conditions
}
// You can add as many loot entries in a single alternative loot entry
itemLoot(Items.STICK) // Create a item loot entry, you can pass item or block.
tagLoot(ItemTags.WOOL) // Create a tag loot entry
tableLoot(ResourceLocation("grass_block")) // Create a table loot entry
alternativesLoot { // Create a alternative loot entry
itemLoot(Items.ITEM_FRAME)
// ... Add more loot entries here
}
dynamicLoot(ShulkerBoxBlock.CONTENTS) // Create a dynamic loot entry
emptyLoot {
weight(2) // Optional
quality(2) // Optional
}
}
Notice that alternative loot entry does not have function
, weight
and quality
.
There are lots of loot functions, checkout source code for more info.
// ... We take Loot Table's function as example
function {
copyName(CopyName.Source.BLOCK_ENTITY)
copyNbt(CopyNbt.Source.BLOCK_ENTITY) {
copy("inv", "BlockEntityTag.inv", CopyNbt.Action.REPLACE)
copy("energy", "BlockEntityTag.energy", CopyNbt.Action.REPLACE)
}
content {
itemLoot(Items.ACACIA_BOAT)
}
}
// ...
There are lots of loot conditions, checkout source code for more info.
// ... We take Loot Pool's conditions as example
condition {
randomChance(0.1f)
surviveExplosion()
}
// ...
You can make nbt compound with data gen dsl, here's an example:
nbt { // this top-level-function creates a nbt compound
int("integer", 1) // define key "integer" with integer value 1
int("integer") { // or you can defines a key in this way
// Evaluate your integer value here
}
compound("compound") { // define key "compound" with a nbt compound
// ...
}
list("list", listOf("yap", "this", "is", "example")) // define key "list" with list of strings
list("compoundList") { // You might want to define a compound list in this way
compound {
// ...
}
}
list("ughh") { // Highly not recommended
number(1)
number(2)
}
intArray("intArray", listOf(1, 2, 3)) // defines key "intArray" with a list of integers
}
// ... We take LanguageProvider's function `addTranslations` as example
override fun addTranslations() {
lang {
Blocks.STONE to "Stone"
Items.DIAMOND to "Diamond"
Effects.POISON to "Poison"
Enchantments.SHARPNESS to "Sharpness"
EntityType.CAT to "Cat"
"$MODID.test.unicode" to "\u0287s\u01DD\u2534 \u01DDpo\u0254\u1D09u\u2229"
}
}