Overview
The SpellEngineAdvancementHelper provides utility methods for creating Spell Engine advancements with custom triggers like spell book creation, spell binding, and spell casting.
This class is located in net.more_rpg_classes.datagen.SpellEngineAdvancementHelper.
Class Definition
public class SpellEngineAdvancementHelper
Enums
SpellEngineTrigger
Defines available Spell Engine advancement triggers.
public enum SpellEngineTrigger {
SPELL_BOOK_CREATION ( "spell_engine:spell_book_creation" ),
SPELL_BINDING ( "spell_engine:spell_binding" ),
SPELL_CAST ( "spell_engine:spell_cast" );
public String getId () {
return triggerId;
}
}
Triggered when a spell book is created for a specific spell pool
Triggered when spells are bound (can check for partial or complete binding)
Triggered when a specific spell or spell tag is cast
Records
AdvancementEntry
Data structure for advancement metadata and localization.
public record AdvancementEntry (
String modId,
String name,
String title,
String description
)
Advancement identifier name
Display title for the advancement
Description text for the advancement
Helper Methods
public String titleKey () {
return "advancements." + modId + "." + name + ".title" ;
}
public String descriptionKey () {
return "advancements." + modId + "." + name + ".description" ;
}
public Identifier id () {
return Identifier . of (modId, name);
}
Criteria Methods
These methods generate JSON criteria objects for advancement triggers.
criteriaSpellBookCreation
Creates criteria for when a spell book is created.
The spell pool identifier (e.g., “mymod:fire_spells”)
Criteria JSON object for spell book creation
public static JsonObject criteriaSpellBookCreation ( String spellPool)
Usage Example
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellBookCreation ( "mymod:arcane" );
Generated JSON
{
"book" : {
"trigger" : "spell_engine:spell_book_creation" ,
"conditions" : {
"spell_pool" : "mymod:arcane"
}
}
}
criteriaOneSpellBound
Creates criteria for when at least one spell from a pool is bound.
The spell pool identifier
Criteria JSON object for partial spell binding
public static JsonObject criteriaOneSpellBound ( String spellPool)
Usage Example
JsonObject criteria = SpellEngineAdvancementHelper . criteriaOneSpellBound ( "mymod:fire" );
Generated JSON
{
"bind" : {
"trigger" : "spell_engine:spell_binding" ,
"conditions" : {
"complete" : false ,
"spell_pool" : "mymod:fire"
}
}
}
criteriaAllSpellsBound
Creates criteria for when all spells from a pool are bound.
The spell pool identifier
Criteria JSON object for complete spell binding
public static JsonObject criteriaAllSpellsBound ( String spellPool)
Usage Example
JsonObject criteria = SpellEngineAdvancementHelper . criteriaAllSpellsBound ( "mymod:frost" );
Generated JSON
{
"bind" : {
"trigger" : "spell_engine:spell_binding" ,
"conditions" : {
"complete" : true ,
"spell_pool" : "mymod:frost"
}
}
}
criteriaSpellCast
Creates criteria for when a specific spell or spell tag is cast.
Spell identifier or tag (e.g., “mymod:fireball” or “#mymod:offensive”)
Criteria JSON object for spell casting
public static JsonObject criteriaSpellCast ( String spellOrTag)
Usage Example
// For a specific spell
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellCast ( "mymod:fireball" );
// For a spell tag
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellCast ( "#arsenal:offensive" );
Generated JSON
{
"cast" : {
"trigger" : "spell_engine:spell_cast" ,
"conditions" : {
"spell" : "mymod:fireball"
}
}
}
Writing Advancements
writeAdvancement
Writes an advancement JSON file to the output directory.
Base output path for data generation
Advancement file name (without .json extension)
Complete advancement JSON object
public static void writeAdvancement (
Path outputPath,
String modId,
String name,
JsonObject json
) throws IOException
Complete Usage Examples
Creating a Spell Book Advancement
import com.google.gson.JsonObject;
import net.more_rpg_classes.datagen.SpellEngineAdvancementHelper;
import java.nio.file.Path;
public class MyAdvancements {
public static void generateAdvancements ( Path outputPath ) throws Exception {
JsonObject advancement = new JsonObject ();
// Add parent (optional)
advancement . addProperty ( "parent" , "mymod:root" );
// Add display
JsonObject display = new JsonObject ();
JsonObject icon = new JsonObject ();
icon . addProperty ( "item" , "spell_engine:spell_book" );
display . add ( "icon" , icon);
JsonObject title = new JsonObject ();
title . addProperty ( "translate" , "advancements.mymod.first_spell_book.title" );
display . add ( "title" , title);
JsonObject description = new JsonObject ();
description . addProperty ( "translate" , "advancements.mymod.first_spell_book.description" );
display . add ( "description" , description);
advancement . add ( "display" , display);
// Add criteria
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellBookCreation ( "mymod:arcane" );
advancement . add ( "criteria" , criteria);
// Write to file
SpellEngineAdvancementHelper . writeAdvancement (
outputPath,
"mymod" ,
"first_spell_book" ,
advancement
);
}
}
Master Spellcaster Advancement
public static void createMasterSpellcasterAdvancement ( Path outputPath) throws Exception {
JsonObject advancement = new JsonObject ();
advancement . addProperty ( "parent" , "mymod:spell_apprentice" );
// Display
JsonObject display = new JsonObject ();
JsonObject icon = new JsonObject ();
icon . addProperty ( "item" , "mymod:master_tome" );
display . add ( "icon" , icon);
JsonObject title = new JsonObject ();
title . addProperty ( "translate" , "advancements.mymod.master_spellcaster.title" );
display . add ( "title" , title);
JsonObject description = new JsonObject ();
description . addProperty ( "translate" , "advancements.mymod.master_spellcaster.description" );
display . add ( "description" , description);
advancement . add ( "display" , display);
// Criteria: All spells must be bound
JsonObject criteria = SpellEngineAdvancementHelper . criteriaAllSpellsBound ( "mymod:arcane" );
advancement . add ( "criteria" , criteria);
// Requirements (all criteria must be met)
JsonObject requirements = new JsonObject ();
advancement . add ( "requirements" , requirements);
SpellEngineAdvancementHelper . writeAdvancement (
outputPath,
"mymod" ,
"master_spellcaster" ,
advancement
);
}
Cast Specific Spell Advancement
public static void createFirstFireballAdvancement ( Path outputPath) throws Exception {
JsonObject advancement = new JsonObject ();
advancement . addProperty ( "parent" , "mymod:first_spell_book" );
JsonObject display = new JsonObject ();
JsonObject icon = new JsonObject ();
icon . addProperty ( "item" , "minecraft:fire_charge" );
display . add ( "icon" , icon);
JsonObject title = new JsonObject ();
title . addProperty ( "translate" , "advancements.mymod.first_fireball.title" );
display . add ( "title" , title);
JsonObject description = new JsonObject ();
description . addProperty ( "translate" , "advancements.mymod.first_fireball.description" );
display . add ( "description" , description);
advancement . add ( "display" , display);
// Criteria: Cast the fireball spell
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellCast ( "mymod:fireball" );
advancement . add ( "criteria" , criteria);
SpellEngineAdvancementHelper . writeAdvancement (
outputPath,
"mymod" ,
"first_fireball" ,
advancement
);
}
Using AdvancementEntry Record
public class AdvancementGenerator {
private static final AdvancementEntry FIRST_BOOK = new AdvancementEntry (
"mymod" ,
"first_spell_book" ,
"Your First Spell Book" ,
"Create your first arcane spell book"
);
public static void generate ( Path outputPath , TranslationBuilder translations ) throws Exception {
// Add translations
translations . add ( FIRST_BOOK . titleKey (), FIRST_BOOK . title ());
translations . add ( FIRST_BOOK . descriptionKey (), FIRST_BOOK . description ());
// Create advancement
JsonObject advancement = new JsonObject ();
JsonObject display = new JsonObject ();
JsonObject title = new JsonObject ();
title . addProperty ( "translate" , FIRST_BOOK . titleKey ());
display . add ( "title" , title);
JsonObject description = new JsonObject ();
description . addProperty ( "translate" , FIRST_BOOK . descriptionKey ());
display . add ( "description" , description);
advancement . add ( "display" , display);
JsonObject criteria = SpellEngineAdvancementHelper . criteriaSpellBookCreation ( "mymod:arcane" );
advancement . add ( "criteria" , criteria);
SpellEngineAdvancementHelper . writeAdvancement (
outputPath,
FIRST_BOOK . modId (),
FIRST_BOOK . name (),
advancement
);
}
}
File Output
Advancements are written to:
data/<modId>/advancement/<name>.json
For example:
data/mymod/advancement/first_spell_book.json
data/mymod/advancement/master_spellcaster.json
Integration with Data Generators
public class MyDatagen implements DataGeneratorEntrypoint {
@ Override
public void onInitializeDataGenerator ( FabricDataGenerator fabricDataGenerator ) {
FabricDataGenerator . Pack pack = fabricDataGenerator . createPack ();
pack . addProvider (( FabricDataOutput output, CompletableFuture registries) -> {
return new DataProvider () {
@ Override
public CompletableFuture < ? > run ( DataWriter writer ) {
try {
Path outputPath = output . getOutputFolder ();
MyAdvancements . generateAdvancements (outputPath);
} catch ( Exception e ) {
e . printStackTrace ();
}
return CompletableFuture . completedFuture ( null );
}
@ Override
public String getName () {
return "My Advancements" ;
}
};
});
}
}
Data Generation Helpers Main data generation providers
Smithing Recipes Generate smithing transform recipes