开物镇居民 · 管理
模块 ID npc,MiaoSkyCore 分支 main。玩家视角的说明见开物镇居民。
命令一览
/msc npc choose <令牌>/msc npc list|tp <NPC>|sethere <NPC>|respawn|interact <NPC> [玩家]/msc town clock <+小时|-小时|yyyy-MM-ddTHH:mm|reset>
权限
| 权限 | 默认 | 说明 |
|---|---|---|
miaoskycore.npc.admin | OP | 管理开物镇居民 |
miaoskycore.town.admin | undefined | 调整开物镇时钟(测试用) |
说明
以下内容摘自 MiaoSkyCore docs/MODULES.md。
职责 不依赖 Citizens 的轻量 NPC。实体是关闭 AI 的村民:setAI(false)、无声、无敌、不可碰撞、无重力、不持久化(不写进区块存档,所在区块加载时由每 2 秒一次的检查生成,卸载时移除)、村民等级 2(不会因为附近没有工作站点丢职业);右键交易界面被取消。附近 6 格内有玩家时转头看向最近的玩家(每 5 刻一次)。选型理由见 (内部文档) §1。
交互 右键(PlayerInteractEntityEvent)与左键(Paper 的 PrePlayerAttackEntityEvent)都会触发,同一玩家 400 毫秒防抖(debounce-millis)。依次执行 interact 里的步骤:
| 步骤 | 含义 |
|---|---|
say: 文字 | 以 NPC 口吻在聊天栏说一句 |
dialog: ID | 显示 dialogs.<ID> 的文字和可点击的选项(点击执行 /msc npc choose <令牌>,令牌一次有效,离 NPC 超过 10 格失效) |
action: 键 [参数] | 其他模块登记的动作 |
command: / console: | 以玩家 / 控制台执行命令({player} 为玩家名) |
sound: | 播放声音 |
已登记的动作键:resident:talk(blueprints)、contracts:open、exchange:open、festival:host、mail:open(邮局)、island:open [命令](空岛事务所,默认执行 /is)。矿业公司的 mining:open 由 msc-world 的矿权地块模块登记;没登记的动作提示「这里暂时不办理这项事务」。
配置 npc.yml debounce-millis、look-range、npcs.<ID>(name、appearance.profession/type/baby、location.world/x/y/z/yaw/pitch、look-at-player、interact)、dialogs.<ID>(text、options[].text/run)。默认 20 位:14 位居民 + 6 位功能 NPC,坐标是围着出生点的占位值。
命令 /msc npc list|tp <NPC>|sethere <NPC>|respawn|interact <NPC> [玩家](权限 miaoskycore.npc.admin);/msc npc choose <令牌>(对话选项,所有人)。/msc town clock <+小时|-小时|yyyy-MM-ddTHH:mm|reset>(权限 miaoskycore.town.admin,调整开物镇时钟,测试用)。
接口 NpcService:registerAction、unregisterAction、npcIds、name、location、say、interact。事件 NpcInteractEvent(player, npcId)(过了防抖之后)。
配置
文件 plugins/MiaoSkyCore/npc.yml(默认值):
展开 npc.yml
# 开物镇居民(NPC)
# 实体:关闭 AI 的村民(不持久化,区块加载时生成)。坐标是占位值,开物镇建好后用 /msc npc sethere <ID> 逐个摆放。
# appearance.profession:村民职业(none farmer fisherman shepherd fletcher librarian cartographer cleric armorer
# weaponsmith toolsmith butcher leatherworker mason nitwit);appearance.type:plains desert jungle savanna snow swamp taiga
# appearance.skin:保留给以后改用玩家外观时的皮肤纹理(当前实现不使用)
# interact:右键与左键都会依次执行这些步骤:
# say: 文字 以 NPC 口吻说一句话(聊天栏)
# dialog: 对话 ID 显示 dialogs 里的一段对话和可点击的选项
# action: 键 [参数] 其他模块登记的动作,如 resident:talk、contracts:open、exchange:open、festival:host、mail:open、island:open
# command: 命令 以玩家身份执行;console: 命令 以控制台执行({player} 为玩家名)
# sound: 声音名 对玩家播放(如 entity.villager.ambient)
# 同一玩家两次点击的最短间隔(毫秒)
debounce-millis: 400
# 附近有玩家时转头看向最近的玩家(格)
look-range: 6
npcs:
baker:
name: '&e罗莎'
title: 烘焙师 罗莎
place: 烘焙坊
appearance:
profession: farmer
type: plains
location:
world: world
x: 12.5
y: 64.0
z: 0.5
yaw: 90
pitch: 0
interact:
- action: 'resident:talk'
clockmaker:
name: '&e老秦'
title: 钟表匠 老秦
place: 钟表店
appearance:
profession: toolsmith
type: plains
location:
world: world
x: 12.0
y: 64.0
z: 4.0
yaw: 107
pitch: 0
interact:
- action: 'resident:talk'
blacksmith:
name: '&e石大锤'
title: 铁匠 石大锤
place: 铁匠铺
appearance:
profession: weaponsmith
type: plains
location:
world: world
x: 10.4
y: 64.0
z: 7.3
yaw: 124
pitch: 0
interact:
- action: 'resident:talk'
brewer:
name: '&e葛老板'
title: 酿酒师 葛老板
place: 酿酒坊
appearance:
profession: cleric
type: plains
location:
world: world
x: 8.0
y: 64.0
z: 9.9
yaw: 141
pitch: 0
interact:
- action: 'resident:talk'
postman:
name: '&e小周'
title: 邮差 小周
place: 邮局
appearance:
profession: cartographer
type: plains
location:
world: world
x: 4.9
y: 64.0
z: 11.7
yaw: 159
pitch: 0
interact:
- action: 'resident:talk'
newsboy:
name: '&e阿福'
title: 报童 阿福
place: 车站广场
appearance:
profession: none
type: plains
location:
world: world
x: 1.4
y: 64.0
z: 12.5
yaw: 176
pitch: 0
interact:
- action: 'resident:talk'
record_dealer:
name: '&e温先生'
title: 唱片行老板 温先生
place: 唱片行
appearance:
profession: librarian
type: plains
location:
world: world
x: -2.2
y: 64.0
z: 12.2
yaw: -167
pitch: 0
interact:
- action: 'resident:talk'
gardener:
name: '&e柳婆婆'
title: 园丁 柳婆婆
place: 节庆广场
appearance:
profession: farmer
type: plains
location:
world: world
x: -5.5
y: 64.0
z: 10.9
yaw: -150
pitch: 0
interact:
- action: 'resident:talk'
lighthouse_keeper:
name: '&e老海'
title: 灯塔看守人 老海
place: 云港
appearance:
profession: fisherman
type: plains
location:
world: world
x: -8.3
y: 64.0
z: 8.7
yaw: -133
pitch: 0
interact:
- action: 'resident:talk'
tailor:
name: '&e苏娘子'
title: 裁缝 苏娘子
place: 裁缝铺
appearance:
profession: shepherd
type: plains
location:
world: world
x: -10.3
y: 64.0
z: 5.7
yaw: -116
pitch: 0
interact:
- action: 'resident:talk'
pharmacist:
name: '&e白先生'
title: 药剂师 白先生
place: 药铺
appearance:
profession: cleric
type: plains
location:
world: world
x: -11.4
y: 64.0
z: 2.3
yaw: -99
pitch: 0
interact:
- action: 'resident:talk'
conductor:
name: '&e陈师傅'
title: 列车长 陈师傅
place: 车站
appearance:
profession: armorer
type: plains
location:
world: world
x: -11.4
y: 64.0
z: -1.3
yaw: -81
pitch: 0
interact:
- action: 'resident:talk'
painter:
name: '&e林小满'
title: 画家 林小满
place: 画室
appearance:
profession: mason
type: plains
location:
world: world
x: -10.3
y: 64.0
z: -4.7
yaw: -64
pitch: 0
interact:
- action: 'resident:talk'
astronomer:
name: '&e沈先生'
title: 天文学者 沈先生
place: 天文台门口
appearance:
profession: librarian
type: plains
location:
world: world
x: -8.3
y: 64.0
z: -7.7
yaw: -47
pitch: 0
interact:
- action: 'resident:talk'
island_clerk:
name: '&e文书'
place: 空岛事务所
appearance:
profession: librarian
type: plains
location:
world: world
x: -5.5
y: 64.0
z: -9.9
yaw: -30
pitch: 0
interact:
- say: '&e文书:&f要建岛还是办岛上的手续?'
- action: 'island:open'
mining_manager:
name: '&e经理'
place: 矿业公司
appearance:
profession: toolsmith
type: plains
location:
world: world
x: -2.2
y: 64.0
z: -11.2
yaw: -13
pitch: 0
interact:
- say: '&e经理:&f矿权地块按周租用。租用资格看你们空岛的岛屿等级和发电量。'
- action: 'mining:open'
exchange_keeper:
name: '&e掌柜'
place: 交易所
appearance:
profession: cartographer
type: plains
location:
world: world
x: 1.4
y: 64.0
z: -11.5
yaw: 4
pitch: 0
interact:
- say: '&e掌柜:&f收购价都写在牌子上,每人每天有限额。'
- action: 'exchange:open'
town_clerk:
name: '&e书记员'
place: 镇公所
appearance:
profession: librarian
type: plains
location:
world: world
x: 4.9
y: 64.0
z: -10.7
yaw: 21
pitch: 0
interact:
- dialog: town_clerk
post_clerk:
name: '&e柜员'
place: 邮局
appearance:
profession: cartographer
type: plains
location:
world: world
x: 8.0
y: 64.0
z: -8.9
yaw: 39
pitch: 0
interact:
- say: '&e柜员:&f你的邮件都在这里。'
- action: 'mail:open'
festival_host:
name: '&e司仪'
place: 节庆广场
appearance:
profession: cleric
type: plains
location:
world: world
x: 10.4
y: 64.0
z: -6.3
yaw: 56
pitch: 0
interact:
- action: 'festival:host'
dialogs:
town_clerk:
text:
- '&e书记员:&f本周的工业订单都在这里,交付也在这里办。'
options:
- text: '&e[查看本周的工业订单]'
run:
- action: 'contracts:open'
- text: '&e[查看工业指数榜]'
run:
- command: msc top index
- text: '&e[查看订单贡献榜]'
run:
- command: msc top orders