Craft Engine
概述
Craft Engine 将 CraftEngine 与 TypeWriter 连接起来。你的自定义方块、家具和物品都会成为任务可以响应的对象:玩家破坏、放置或点击它们时触发的事件、统计它们的目标、读取玩家持有或注视内容的 fact 和变量,以及放置、替换或移除它们的动作。
该扩展的另一半是任务区域(quest zone)。任务区域为每位玩家提供各自版本的一片区域。玩家破坏、放置或更改的内容只会为该玩家记录,以数据包的形式发送给他们,并在他们回来时还原。真实世界从不会被写入,因此离开区域不会有任何代价,即使服务器在任务进行到一半时停止,也不会留下任何未完成的状态。区域也可以由一个组共享,这样队伍就能一起清理一个房间。
该扩展为 Paper 和 Folia 编写:每一次对世界或物品栏的更改,都会在拥有它的区域线程上运行。
功能
- 方块和家具事件 — 响应自定义方块和家具被破坏、放置、交互或被击打,包括被拒绝的放置。
- 放置规则 — 除非玩家持有某个权限或满足条件,否则拒绝放置或击打。
- 计数目标 — 将破坏、放置或替换自定义方块和家具作为任务目标;每个位置对每位玩家只计数一次。
- 世界动作 — 放置、移除或替换方块或家具,并在已放置的家具上存储你自己的数据。
- 任务区域 — 按玩家(或按组)的方块和家具视图,在多次访问之间被保留。
- 物品栏交换 — 进入区域时收走玩家的整个物品栏或仅收走选定物品,离开时归还。
- Fake block audience — 向某个 audience 显示一组固定的方块和家具,而不记录任何内容。
- 物品工具 — 按 id 给予或移除 CraftEngine 物品,并响应拾取、丢弃或食用它们。
- Fact、变量和 audience — 读取手持物品、正在注视的方块或家具、冷却时间,并按玩家持有或坐着的东西对其分组。
安装
- 在服务器上安装 CraftEngine。该扩展基于 CraftEngine 26.8 构建。
- 确保已安装 TypeWriter 的 Quest 扩展。它提供了目标所使用的任务和目标条目。
- 从商店下载该扩展(见上方面板中的按钮),并将 JAR 放入
plugins/Typewriter/extensions/。 - 重启服务器。你应该会在日志中看到
[CraftEngine] CraftEngineExtension initialized successfully.
快速上手
本教程为每位玩家在解谜房间中提供各自独立、可破坏的封印。
- 在网页面板中,打开一个 manifest 页面,添加一个 Quest State Artifact。保持
artifactId为自动生成的值。 - 添加一个 Quest Zone Audience,并将
artifact设为你刚创建的 artifact。让zoneId留空,这样它会使用条目 id,并保持trackBlocks开启。 - 将该区域 audience 嵌套在决定谁处于房间内的 audience 之下(例如区域 audience 或任务 audience)。进入的玩家会获得各自的视图。
- 在一个 sequence 页面上,为你的封印方块添加一个 On Block Interact 事件。它会触发一个 Set Quest Block 动作。
- 在该动作中,将
artifact和zoneId设为与区域相同的值(复制区域的条目 id),将location绑定到事件的位置,并将blockId设为被破坏后的封印(namespace:broken_seal)。留空则显示为空气。 - 在任务结束的地方添加一个 Clear Quest State 动作,这样房间可以被再次解开。
- Publish(发布),然后用两位玩家检查:每个人都打开自己的封印,而另一个人看到的仍然是完好的。
对于单纯的计数任务,不需要区域:添加一个 Break Block 目标,在 item 中填写方块 id,并设置 amount。
工作原理
在区域中所做的更改是一种偏差(deviation):发送给某一位玩家、叠加在真实方块之上的方块;对某一位玩家隐藏的世界家具;或者是幽灵(ghost),即仅为该玩家存在的家具。幽灵可以被其观看者右键点击和破坏,但对任何人都没有碰撞。
碰撞始终遵循真实世界。玩家破坏的方块仍然会挡住他们,他们放置的方块可以穿过,被隐藏的世界家具仍然会挡住看不到它的玩家。请把区域构建成更改是用来观看和使用的内容,而不是用来站立的东西。
状态会在最后一次更改之后几秒写入 artifact,并在玩家离开区域或服务器停止时立即写入。如果服务器是被强制终止而不是正常停止,可能会丢失最后几秒的数据。
配置
该扩展没有配置文件。目标行的文本可以通过 TypeWriter 的片段(snippet)修改:
| 片段 | 默认值 |
|---|---|
craftengine.objective.display | <display> <dark_gray>(<gray><current><dark_gray>/<gray><required><dark_gray>) |
craftengine.objective.completed | <green>✔</green> <st><display></st> <dark_gray>(<gray><current><dark_gray>/<gray><required><dark_gray>) |
条目
49 个条目,由扩展源码生成。
动作10
- Craftengine Clear Quest StateDrop a player's own state for a quest zone
- Craftengine Give Item ActionGive a CraftEngine item to the player
- Craftengine Remove Item ActionRemove a CraftEngine item from the player
- Craftengine Set Quest BlockChange what one player sees at a spot, inside a quest zone — a block or a piece of furniture
- Craftengine Set Quest FurnitureHide or show one piece of the world's furniture, for one player, inside a quest zone
- Place Craftengine BlockPlace a CraftEngine block at a location
- Place Craftengine FurniturePlace a CraftEngine furniture at a location
- Remove Craftengine BlockRemove the CraftEngine block at a location
- Remove Craftengine FurnitureRemove the CraftEngine furniture at a location
- Replace Craftengine BlockReplace the block or furniture at a location with another one
事件13
- Craftengine on Item Consume EventTriggers when the player consumes a CraftEngine item
- Craftengine on Item Drop EventTriggers when the player drops a CraftEngine item
- Craftengine on Item Pickup EventTriggers when the player picks up a CraftEngine item
- On Craftengine Block Attempt Place EventTriggers when a player attempts to place a CraftEngine block
- On Craftengine Block Break EventTriggers when a CraftEngine custom block is broken
- On Craftengine Block Interact EventTriggers when a CraftEngine custom block is interacted with
- On Craftengine Block Place EventTriggers when a CraftEngine custom block is placed
- On Craftengine Dispense Projectile EventTriggers when a dispenser shoots a CraftEngine projectile
- On Craftengine Furniture Attempt Place EventTriggers when a player attempts to place CraftEngine furniture
- On Craftengine Furniture Break EventTriggers when a CraftEngine furniture is broken
- On Craftengine Furniture Hit EventTriggers when a player hits CraftEngine furniture
- On Craftengine Furniture Interact EventTriggers when a CraftEngine furniture is interacted with
- On Craftengine Furniture Place EventTriggers when a CraftEngine furniture is placed
目标5
- Break Craftengine Block ObjectiveAn objective to break CraftEngine custom blocks
- Break Craftengine Furniture ObjectiveAn objective to break CraftEngine furniture
- Place Craftengine Block ObjectiveAn objective to place CraftEngine custom blocks
- Place Craftengine Furniture ObjectiveAn objective to place CraftEngine furniture
- Replace Craftengine Block ObjectiveAn objective to replace a block with another one
事实8
- Craftengine Cooldown Active FactWhether a CraftEngine cooldown is currently running
- Craftengine Cooldown Remaining FactSeconds left on a CraftEngine cooldown
- Craftengine Holding Item FactWhether the player is holding a CraftEngine item
- Craftengine Item Cooldown FactTicks left on the vanilla use cooldown of an item
- Craftengine Item Count FactHow many of a CraftEngine item the player carries
- Craftengine Looking at Block FactWhether the player is looking at a CraftEngine block
- Craftengine Looking at Furniture FactWhether the player is looking at CraftEngine furniture
- Craftengine Standing on Block FactWhether the player is standing on a CraftEngine block
受众5
- Craftengine Fake Block AudienceShow blocks and furniture to this audience alone
- Craftengine Furniture Proximity AudienceIn audience while near a CraftEngine furniture
- Craftengine Holding Item AudienceIn audience while holding a CraftEngine item
- Craftengine Quest Zone AudienceKeep a player's own block, furniture and item state for a quest zone
- Craftengine Sitting on Furniture AudienceIn audience while sitting on a CraftEngine furniture
变量6
- Craftengine Item in Hand ID VariableThe CraftEngine ID of the item the player holds
- Craftengine Item Property VariableA property of the CraftEngine item the player holds
- Craftengine Looking at Block ID VariableThe CraftEngine ID of the block the player is looking at
- Craftengine Looking at Furniture ID VariableThe CraftEngine ID of the furniture the player is looking at
- Craftengine Registry Ids VariableThe list of IDs CraftEngine has loaded
- Craftengine Standing on Block ID VariableThe CraftEngine ID of the block the player stands on
声音1
- Craftengine SoundCraftEngine Sound
构件1
- Craftengine Quest State ArtifactArtifact storing per-player quest block and item state
故障排查
任务区域什么也不显示,也没有出现错误。 动作和 audience 必须指定相同的 artifact、zoneId 和 group。以另一个名称归档的更改虽然被正确写入,但没有人会读取它。当 audience 上的 zoneId 为空时,你必须复制的是该 audience 自己的条目 id。
Set Quest Block 没有任何效果,日志显示 “has no zone configured”。 动作上的 zoneId 为空。请设置它。对于 Set Quest Furniture,同样适用。
日志显示 “cannot resolve” 某个 id。 blockId 既不是 CraftEngine 方块、CraftEngine 家具,也不是原版材质。请使用 Registry IDs 检查该 id。当 kind 设为 FURNITURE 时,不是家具的 id 会被拒绝,而不是显示为方块。
区域内的所有人都看到相同的更改。 该动作写入了真实世界。Place 和 Remove 动作,以及设为 WORLD 的 Replace Block,会更改真实的方块。在区域内请使用 Set Quest Block、Set Quest Furniture,或将 audience 设为 AUTO 或 QUEST_ZONE 的 Replace Block。
对于处在两个区域中的玩家,Replace Block 没有任何效果。 当存在多个重叠的区域且没有 zoneId 时,该动作会拒绝执行,并在日志中写入一行记录。请将 zoneId 设为你所指的区域。
走了很远之后,更改又闪回去了。 重新加载区块的客户端会再次获得真实世界,而区域会在 refreshRadius 格范围内,每隔 refreshInterval 个 tick 重新发送其视图。请降低 refreshInterval 或提高 refreshRadius。
在区域中被破坏的方块,方块事件没有触发。 开启 trackBlocks 后,区域会接管该操作:破坏或放置会被取消,并记录为一个偏差。请改为通过交互事件或 Set Quest Block 来推进任务。
相关扩展
- Nexo 和 ItemsAdder — 针对其他自定义内容插件的同类集成。