Chemdah 开发者文档:自定义对话触发器
来自Purtmars Wikipedia —— 普特莫斯维基
目录
- 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:foo 的对话。
1 ConversationManager.getConversation("minecraft", "foo")
通过以下方法实现具体逻辑:
1 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
2 fun e(e: PlayerInteractAtEntityEvent) {
3 // 主手交互实体并不在对话中
4 if (e.hand == EquipmentSlot.HAND && e.player.conversationSession == null) {
5 // 获取实体名称
6 val name = I18n.get().getName(e.rightClicked)
7 // 获取有效对话
8 val conversation = ConversationManager.getConversation("minecraft", name) ?: return
9 // 获取原点(对话实体的头顶坐标,用于播放粒子和定位)
10 val origin = e.rightClicked.location.add(0.0, e.rightClicked.height, 0.0)
11 // 打开对话
12 conversation.open(e.player, origin, npcName = name, npcObject = e.rightClicked)
13 // 取消事件
14 e.isCancelled = true
15 }
16 }