“Chemdah 开发者文档:自定义对话触发器”的版本间的差异
来自Purtmars Wikipedia —— 普特莫斯维基
(建立内容为“{{:Chemdah 开发者文档目录}} 实现方法如下: <syntaxhighlight lang="kotlin" line="line"> @EventHandler(priority = EventPriority.MONITOR, ignoreCancel…”的新页面) |
|||
第1行: | 第1行: | ||
{{:Chemdah 开发者文档目录}} | {{:Chemdah 开发者文档目录}} | ||
− | + | = 自定义触发器 = | |
− | + | 参考 '''minecraft''' 类型的实现方法: | |
<syntaxhighlight lang="kotlin" line="line"> | <syntaxhighlight lang="kotlin" line="line"> | ||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) |
2021年4月29日 (四) 00:00的版本
目录
- Chemdah
- 开始
- 基本
- 事件
- ink.ptms.chemdah.api.event.collect.ConversationEvents
- ink.ptms.chemdah.api.event.collect.ObjectiveEvents
- ink.ptms.chemdah.api.event.collect.PlayerEvents
- ink.ptms.chemdah.api.event.collect.QuestEvents
- ink.ptms.chemdah.api.event.collect.TemplateEvents
- ink.ptms.chemdah.api.event.InferEntityHookEvent
- ink.ptms.chemdah.api.event.InferItemHookEvent
- ink.ptms.chemdah.api.event.PartyHookEvent
- 对话相关
- 数据相关
- 任务相关
自定义触发器
参考 minecraft 类型的实现方法:
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
fun e(e: PlayerInteractAtEntityEvent) {
// 主手交互实体并不在对话中
if (e.hand == EquipmentSlot.HAND && e.player.conversationSession == null) {
// 获取实体名称
val name = I18n.get().getName(e.rightClicked)
// 获取有效对话
val conversation = getConversation("minecraft", name) ?: return
// 获取原点(对话实体的头顶坐标,用于播放粒子和定位)
val origin = e.rightClicked.location.add(0.0, e.rightClicked.height, 0.0)
// 打开对话
conversation.open(e.player, origin, npcName = name, npcObject = e.rightClicked)
// 取消事件
e.isCancelled = true
}
}