YARRP - Yet Another Runtime Resource Pack
Have you ever been bothered by the fact that most configurations of blocks, items, recipes, and even enchantments are set in untyped JSON files? If this is your case, and at the same time you need to dynamically modify data or make certain aspects configurable, then this mod can be the perfect solution. YARRP creates resource bundles (including both datapacks and resource bundles) directly during game runtime, eliminating the need to prepare JSON files in advance for all possible options.
Usage
To connect YARRP as a dependency, add the following code to your build.gradle.kts file:
repositories {
// you can use either option
maven("https://jitpack.io")
maven("https://api.modrinth.com/maven")
}
dependencies {
// replace the version and loader as needed, where loader can be fabric or neoforge
modImplementation("com.github.RubixDev.YARRP:yarrp-mc1.21.1-fabric:v0.2.0") // when using jitpack
modImplementation("maven.modrinth:yarrp:0.2.0+1.21.1-fabric") // when using modrinth maven
}
Also, don't forget to specify YARRP as a dependency in the fabric.mod.json and neoforge.mods.toml files.
Next, you can use YARRP by creating a bundle and adding it to one of the registration callback methods. Example implementation:
object MyCustomResources {
// call this method in the mod initializer
fun initialize() {
YarrpRegistration.registration(PackPosition.AFTER_VANILLA, ResourceType.SERVER_DATA) {
add(BUNDLE)
}
}
@JvmField
val BUNDLE = RuntimeResourcePack(
RuntimeResourcePack.info(
Identifier.of("mod_id", "my_dynamic_bundle"),
Text.of("Bundle Title"),
"bundle_version", // recommended to set the mod version
),
RuntimeResourcePack.metadata(Text.of("bundle description")),
)
val MY_SPELL: RegistryKey<Enchantment> = BUNDLE.addEnchantment(
Identifier.of("mod_id", "my_spell"),
Enchantment.definition(
DummyHolderSet(ItemTags.LEG_ARMOR_ENCHANTABLE),
5,
3,
Enchantment.leveledCost(5, 8),
Enchantment.leveledCost(55, 8),
2,
AttributeModifierSlot.LEGS,
),
)
init {
if (CustomModSettings.treasureEnchantment) {
BUNDLE.addTag(EnchantmentTags.TREASURE) { add(MY_SPELL) }
} else {
BUNDLE.addTag(EnchantmentTags.NON_TREASURE) { add(MY_SPELL) }
}
if (CustomModSettings.enableRecipe) {
BUNDLE.addRecipeAndAdvancement(
Identifier.of("mod_id", "my_recipe"),
ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, Items.DIAMOND, 64)
.criterion("tick", TickCriterion.Conditions.createTick())
.pattern("//")
.pattern("//")
.input('/', Items.STICK),
)
}
}
}
Complete API documentation is available on the official project website.