介绍
Triggers
About
Triggers is a library mod that provides a unified, modular, Forge-style event API for in-game triggers and
advancement criteria. It abstracts standard Minecraft triggers (such as item enchantment, block interactions, taming
animals, and earning stats) into an easy-to-use event bus. This allows developers to seamlessly listen to and handle
these actions across multi-loader environments (Forge, Fabric, and NeoForge) without needing to mixin to the triggers
themselves.
For Developers
Adding to your build.gradle
You can easily add Triggers to your development environment using the Modrinth Maven.
First, add the Modrinth maven to your repositories block:
repositories {
exclusiveContent {
forRepository {
maven {
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}
Then, add the mod as a dependency in your dependencies block:
dependencies {
// Replace <version> with the target version of Triggers
implementation "maven.modrinth:triggers:<version>"
}
Example Usage
Triggers uses a custom event bus that functions similarly to Forge’s event bus. You can register listeners to
Triggers.EVENTS and listen for specific events.
import com.evandev.triggers.Triggers;
import com.evandev.triggers.event.events.TriggerEntityEvent;
import com.evandev.triggers.event.events.TriggerPlayerEvent;
public class MyMod {
public static void init() {
// Listen for when a player enchants an item
Triggers.EVENTS.addListener(TriggerPlayerEvent.Enchant.class, event -> {
System.out.println(event.player.getName().getString() + " enchanted " + event.item);
});
// Listen for when an animal is tamed
Triggers.EVENTS.addListener(TriggerEntityEvent.TameAnimal.class, event -> {
if (event.causedByPlayer != null) {
System.out.println("Animal tamed by: " + event.causedByPlayer.getName().getString());
}
});
}
}
License
常见问题
Triggers 支持哪些 Minecraft 版本?
Triggers 支持 Minecraft Java 版 1.20.1–1.21.1,共 2 个版本,可用的加载器:Fabric / Forge / NeoForge。下载时注意选择和你游戏版本一致的文件。
Triggers 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / Forge / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。
evanbones 的其他作品
查看全部 →Shield Expansion
为盾牌加入弹反、附魔、等级和自定义功能,让盾牌玩法更有趣!
Cultural Delights
一个为农夫乐事添加世界各地美食系统的附属模组。
Sun and Moon Celestial Configuration
改变太阳和月亮的大小!
Wolf Armor Compat (Fabric)
Adds compatibility between Wolves With Armor and other popular mods
评论
登录后评论和评分