是否曾让你困扰的是,大量的方块、物品、配方定义,以及现在连附魔都定义在无类型 JSON 文件中?如果是这样,你可能应该使用 数据生成,它经过更严格的实战检验,甚至被 Mojang 用于原版数据。但是,如果你 也 希望能够在运行时动态调整数据或使某些内容可配置,那么这可能正是你需要的东西。YARRP 灵感来源于 ARRP 和 BRRP,但采用易于使用的 Kotlin API 从头编写。它允许你在运行时创建资源包(即数据包和资源包),因此你无需为所有可能的选项预先准备好 JSON 文件。
用法
要将 YARRP 添加为依赖项,请将以下内容添加到你的 build.gradle.kts 中:
repositories {
// 你可以选择其中一个
maven("https://jitpack.io")
maven("https://api.modrinth.com/maven")
}
dependencies {
// 根据需要替换版本和加载器。加载器可以是 `fabric` 或 `neoforge` 之一
modImplementation("com.github.RubixDev.YARRP:yarrp-mc1.21.1-fabric:v0.2.0") // 当使用 jitpack 时
modImplementation("maven.modrinth:yarrp:0.2.0+1.21.1-fabric") // 当使用 modrinth maven 时
}
别忘了在 fabric.mod.json 和 neoforge.mods.toml 文件中也将 YARRP 列为依赖项。
然后,你可以通过创建一个包并将其添加到其中一个注册回调中来使用 YARRP。以下是一个示例:
object MyModResources {
// 在你的模组初始化程序中调用此方法
fun register() {
YarrpCallbacks.register(PackPosition.AFTER_VANILLA, ResourceType.SERVER_DATA) {
add(PACK)
}
}
@JvmField
val PACK = RuntimeResourcePack(
RuntimeResourcePack.createInfo(
Identifier.of("modid", "my_runtime_pack"),
Text.of("Pack Title"),
"pack version", // 应设置为模组的版本
),
RuntimeResourcePack.createMetadata(Text.of("pack description")),
)
val MY_ENCHANTMENT: RegistryKey<Enchantment> = PACK.addEnchantment(
Identifier.of("modid", "my_enchantment"),
Enchantment.definition(
// 这个虚拟类型可用于从给定的 TagKey 创建 RegistryEntryList
// 但仅应用于向运行时包添加资源
DummyHolderSet(ItemTags.LEG_ARMOR_ENCHANTABLE),
5,
3,
Enchantment.leveledCost(5, 8),
Enchantment.leveledCost(55, 8),
2,
AttributeModifierSlot.LEGS,
),
)
init {
if (MyModSettings.myEnchantmentIsTreasure) {
PACK.addTag(EnchantmentTags.TREASURE) { add(MY_ENCHANTMENT) }
} else {
PACK.addTag(EnchantmentTags.NON_TREASURE) { add(MY_ENCHANTMENT) }
}
if (MyModSettings.enableRecipe) {
PACK.addRecipeAndAdvancement(
Identifier.of("modid", "my_recipe"),
ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, Items.DIAMOND, 64)
.criterion("tick", TickCriterion.Conditions.createTick())
.pattern("//")
.pattern("//")
.input('/', Items.STICK),
)
}
}
}
完整的 API 文档可在 yarrp.rubixdev.de 找到。
Has it ever bothered you that so much configuration of blocks, items, recipes, and now even enchantments is defined in untyped JSON files? Well then you should probably just use data generation which is much more battle tested and even used by Mojang for the Vanilla data. But, if you also want to be able to adjust the data dynamically or want some things to be configurable, then this might just be the thing for you. YARRP is inspired by ARRP and BRRP but written from the ground up with an easy to use Kotlin API. It allows you to create resource packs (i.e. both data packs and asset packs) at runtime, so you don't need to have JSON files ready for all possible options.
Usage
To add YARRP as a dependency, add the following to your build.gradle.kts:
repositories {
// you can use either one
maven("https://jitpack.io")
maven("https://api.modrinth.com/maven")
}
dependencies {
// replace the versions and loader as needed. the loader is one of `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
}
Don't forget to also list YARRP as a dependency in your fabric.mod.json and
neoforge.mods.toml files.
You can then use YARRP by creating a pack and adding it to one of the register callbacks. Here's an example:
object MyModResources {
// call this in your mod initializer
fun register() {
YarrpCallbacks.register(PackPosition.AFTER_VANILLA, ResourceType.SERVER_DATA) {
add(PACK)
}
}
@JvmField
val PACK = RuntimeResourcePack(
RuntimeResourcePack.createInfo(
Identifier.of("modid", "my_runtime_pack"),
Text.of("Pack Title"),
"pack version", // should probably be set to the version of your mod
),
RuntimeResourcePack.createMetadata(Text.of("pack description")),
)
val MY_ENCHANTMENT: RegistryKey<Enchantment> = PACK.addEnchantment(
Identifier.of("modid", "my_enchantment"),
Enchantment.definition(
// this dummy type can be used to create a RegistryEntryList from a given TagKey
// but should only be used for adding resources to a runtime pack
DummyHolderSet(ItemTags.LEG_ARMOR_ENCHANTABLE),
5,
3,
Enchantment.leveledCost(5, 8),
Enchantment.leveledCost(55, 8),
2,
AttributeModifierSlot.LEGS,
),
)
init {
if (MyModSettings.myEnchantmentIsTreasure) {
PACK.addTag(EnchantmentTags.TREASURE) { add(MY_ENCHANTMENT) }
} else {
PACK.addTag(EnchantmentTags.NON_TREASURE) { add(MY_ENCHANTMENT) }
}
if (MyModSettings.enableRecipe) {
PACK.addRecipeAndAdvancement(
Identifier.of("modid", "my_recipe"),
ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, Items.DIAMOND, 64)
.criterion("tick", TickCriterion.Conditions.createTick())
.pattern("//")
.pattern("//")
.input('/', Items.STICK),
)
}
}
}
Full API documentation can be found at yarrp.rubixdev.de.
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 YARRP
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
修复
- 注册时必须指定资源包类型
AFTER_VANILLA回调未能正常工作- 与部分 Fabric API 版本不兼容(详见 )
新增内容
- 更多调试日志
- 更多注册点
- 更具体的标签构建器,使构建方块标签和物品标签更加简便
其他更改
- 添加了测试代码
构建信息
- 文件名:
yarrp-mc1.20.6-neoforge-v0.2.0.jar - SHA-256:
978bd802930f0de99dc92b9f7aa97004e2d822ea265c7b852aac56e65347436b - 构建来源:
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
缓冲的原始输入和线程化的事件轮询
模组
可定制的鞘翅模组,支持装饰纹饰、旗帜图案等更多功能!
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
原版世界生成优化模组
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
评论 0
登录后参与评分
还没有评论,来抢沙发吧