⌨️ Skript
对于高级 Skript 用户,请使用反射来实现更高级的功能。如果您在使用 CraftEngine 提供的 Skript 功能时遇到问题,请及时向我们反馈。如果您想要请求新的 Skript 功能并且您了解 Java,请考虑通过拉取请求贡献您的代码!
你需要安装 Skript 2.15.0 或更高版本。
类型
CraftEngine 额外注册了两种可存入变量的类型。可通过 parsed as 从字符串解析:
# 完整的不可变方块状态(ID + 属性)
set {_state} to "default:table_lamp[lit=true,facing=east]" parsed as custom block state
# 方块状态匹配器,主要用于事件过滤器
set {_matcher} to "default:table_lamp[lit=true]" parsed as unsafe block state matcher
在效果和事件过滤器中也可以直接使用不带引号的字面量,例如 place custom block default:table_lamp[lit=true] at player。
事件
放置或破坏 CraftEngine 方块事件
事件当放置和破坏 CraftEngine 方块时触发
语法格式:
[on] (break[ing]|1¦min(e|ing)) of (custom|ce|craft-engine) block[s] [[of] %-unsafeblockstatematchers%][on] (plac(e|ing)|build[ing]) of (custom|ce|craft-engine) block[s] [[of] %-unsafeblockstatematchers%]事件字段:
event-block - 事件方块event-location - 事件位置event-player - 事件玩家event-world - 事件世界示例:
on break of ce block default:palm_log[axis=y]:
send "你破坏了自定义方块!" to event-player放置或破坏 CraftEngine 家具事件
事件当放置和破坏 CraftEngine 家具时触发
语法格式:
[on] (break[ing]) of [(custom|ce|craft-engine)] furniture[s] [[of] %-strings%][on] (plac(e|ing)|build[ing]) of [(custom|ce|craft-engine)] furniture[s] [[of] %-strings%]事件字段:
event-entity - 事件实体event-location - 事件位置event-player - 事件玩家event-world - 事件世界示例:
on place of custom furniture default:chinese_lantern:
send "你放置了自定义家具!" to event-player点击 CraftEngine 方块或家具事件
事件当点击 CraftEngine 方块和家具时触发
语法格式:
[on] [(" + RIGHT + ":right|" + LEFT + ":left)(| |-)][mouse(| |-)]click[ing] of (ce|craft-engine) [on %-unsafeblockstatematchers/strings%] [(with|using|holding) %-itemtype%][on] [(" + RIGHT + ":right|" + LEFT + ":left)(| |-)][mouse(| |-)]click[ing] of (ce|craft-engine) (with|using|holding) %itemtype% on %unsafeblockstatematchers/strings%事件字段:
event-block - 事件方块event-entity - 事件实体event-location - 事件位置event-player - 事件玩家event-world - 事件世界示例:
on right-click of craft-engine on default:chinese_lantern:
send "你点击了自定义方块!" to event-playerCraftEngine 重新加载事件
事件当 CraftEngine 加载时触发
语法格式:
[on] (ce|craft(engine|-engine)) [first] (load[ed]|reload)示例:
on craft-engine loaded:
send "嘿,CraftEngine 已加载,现在可以获取 CE 物品了!" to consoleon craft-engine first loaded:
send "嘿,CraftEngine 已在服务器启用时加载,脚本现在将初始化一些内容!" to console击打 CraftEngine 家具事件
事件当玩家击打 CraftEngine 家具时触发,可取消
语法格式:
[on] hit[ting] [of] [(custom|ce|craft-engine)] furniture[s] [[of] %-strings%]事件字段:
event-entity - 事件实体event-location - 事件位置event-player - 事件玩家event-world - 事件世界示例:
on hit of furniture "default:wooden_chair":
cancel event尝试放置 CraftEngine 方块或家具事件
事件当玩家尝试放置自定义方块或家具时触发(先于实际放置),可取消
语法格式:
[on] attempt[ing] to place (custom|ce|craft-engine) block[s] [[of] %-unsafeblockstatematchers%][on] attempt[ing] to place [(custom|ce|craft-engine)] furniture[s] [[of] %-strings%]事件字段:
event-block - 事件方块event-location - 事件位置event-player - 事件玩家event-world - 事件世界示例:
on attempt to place custom block:
cancel event条件
是自定义物品
条件检查物品是否为来自 CraftEngine 的自定义物品
语法格式:
%itemstack/itemtype/slot% (is [a[n]]|are) (custom|ce|craft-engine) item[s]%itemstack/itemtype/slot% (isn't|is not|aren't|are not) [a[n]] (custom|ce|craft-engine) item[s]示例:
on mine:
if event-player's tool is a custom item:
send "你正在使用自定义物品挖掘" to event-player是自定义方块
条件检查方块是否为来自 CraftEngine 的自定义方块
语法格式:
%blocks% (is|are) [a[n]] (custom|ce|craft-engine) block[s]%blocks% (is|are) (n't| not) [a[n]] (custom|ce|craft-engine) block[s]示例:
on mine:
if event-block is custom block:
send "你破坏了一个自定义方块" to event-player是自定义家具
条件检查实体是否为来自 CraftEngine 的自定义家具
语法格式:
%entities% (is|are) [a[n]] [(custom|ce|craft-engine)] furniture[s]%entities% (is|are) (n't| not) [a[n]] [(custom|ce|craft-engine)] furniture[s]示例:
on click:
set {_entity} to nearest pig
if {_entity} is a ce furniture:
send "我在做什么?" to event-player是家具座位
条件检查实体是否为 CraftEngine 家具的座位
语法格式:
%entities% (is|are) [a[n]] [(custom|ce|craft-engine)] furniture seat[s]%entities% (is|are) (n't| not) [a[n]] [(custom|ce|craft-engine)] furniture seat[s]示例:
if target entity is a furniture seat:
send "这是一个座位!" to event-player是家具碰撞体
条件检查实体是否为 CraftEngine 家具的碰撞实体
语法格式:
%entities% (is|are) [a[n]] [(custom|ce|craft-engine)] furniture (collider|collision entit(y|ies))%entities% (is|are) (n't| not) [a[n]] [(custom|ce|craft-engine)] furniture (collider|collision entit(y|ies))示例:
if target entity is a furniture collider:
send "这是一个碰撞体!" to event-player表达式
自定义物品
表达式通过命名空间ID获取自定义物品
语法格式:
[(the|a)] (custom|ce|craft-engine) item [with [namespace] id] %strings%示例:
set {_item} to custom item with namespace id "default:topaz"自定义物品命名空间ID
表达式获取自定义物品的命名空间ID
语法格式:
(custom|ce|craft-engine) item [namespace] id of %itemstack/itemtype/slot%%itemstack/itemtype/slot%'[s] (custom|ce|craft-engine) item [namespace] id示例:
set {_itemId} to craft-engine item id of player's tool自定义方块命名空间ID
表达式获取自定义方块的命名空间ID
语法格式:
%blocks/blockdata/customblockstates%'s (custom|ce|craft-engine) block [namespace] id(custom|ce|craft-engine) block [namespace] id of %blocks/blockdata/customblockstates%示例:
on mine:
if event-block's ce block id is "default:chinese_lantern":
send "破坏了一个中式灯笼方块" to event-player自定义方块状态
表达式获取自定义方块的方块状态
语法格式:
%blocks/blockdata/customblockstates%'s (custom|ce|craft-engine) block[ ]state(custom|ce|craft-engine) block[ ]state of %blocks/blockdata/customblockstates%示例:
on mine:
send event-block's ce block state to event-player家具命名空间ID
表达式从实体获取家具的命名空间ID
语法格式:
%entities%'s [(custom|ce|craft-engine)] furniture [namespace] id示例:
set {_furnitureId} to {_entity}'s craft-engine furniture id自定义方块状态属性
表达式获取或设置自定义方块状态的单个属性。方块状态是不可变的:设置属性会替换变量中存储的状态
语法格式:
(custom|ce|craft-engine) block [state] propert(y|ies) %strings% of %customblockstates%%customblockstates%'[s] (custom|ce|craft-engine) block [state] propert(y|ies) %strings%示例:
set {_s} to "default:table_lamp[lit=true]" parsed as custom block state
set custom block property "facing" of {_s} to "south"
place custom block {_s} at target block自定义方块全部状态
表达式获取自定义方块的所有可能状态
语法格式:
[(all|the)] [possible] [block] states of (custom|ce|craft-engine) block[s] %strings%示例:
loop all states of custom block "default:table_lamp":
send "%loop-value%"家具变体
表达式获取、设置或重置家具实体的变体。重置会恢复默认变体
语法格式:
(custom|ce|craft-engine) furniture variant of %entities%%entities%'[s] (custom|ce|craft-engine) furniture variant示例:
set furniture variant of target entity to "wall"reset furniture variant of target entity家具全部变体
表达式获取家具定义的所有变体名称
语法格式:
[(all|the)] variants of [(custom|ce|craft-engine)] furniture %strings%示例:
send variants of furniture "default:flower_basket" to player效果
放置自定义方块
效果放置一个自定义方块
语法格式:
place (custom|ce|craft-engine) block %customblockstates% [at] [%directions% %locations%]示例:
place custom block default:palm_log[axis=x] at location of the player放置家具
效果放置一个家具,可指定变体
语法格式:
place [(custom|ce|craft-engine)] furniture[s] %strings% [with variant %-strings%] [at] [%directions% %locations%]示例:
place furniture "default:bench" at location of playerplace furniture "default:flower_basket" with variant "wall" at location of player移除自定义方块
效果移除指定位置的自定义方块,非自定义方块会被忽略
语法格式:
(remove|break) (custom|ce|craft-engine) block[s] [at] [%directions% %locations%]示例:
remove custom block at target block移除家具
效果移除一个家具
语法格式:
remove [(custom|ce|craft-engine)] furniture %entities%示例:
remove craft-engine furniture target entity强制设置家具变体
效果强制设置家具实体的变体,跳过碰撞检查。与遵循碰撞检查的 'set furniture variant of ... to ...' 相对
语法格式:
force[fully] set [(custom|ce|craft-engine)] furniture variant of %entities% to %strings%示例:
force set furniture variant of target entity to "ceiling"