world.events.tick.subscribe并不存在(以前有,但所提及版本已废弃),正确做法是注册worldLoad事件再利用System:function handler() {
// 从 World 取得所有玩家
const players = world.getAllPlayers();
player.forEach((player) => {
// Do something...
});
}
// 注意: 所提及版本为1.17.0,将worldLoad换成worldInitialize即可(仍无world.events.tick)
// ScriptV2迁移: https://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/v2-overview?view=minecraft-bedrock-experimental
world.afterEvents.worldLoad.subscribe(() => {
// 用 System 注册回调
system.runInterval(handler);
});
EquipmentSlot是TS接口,除非你用TS写脚本再编译,否则不应当使用(TS的interface在编译成JS时会删除,在特定函数用动态类型检查代替),所以在SAPI的QuickJs语境下是import不到EquipmentSlot的。world.events.tick.subscribe并不存在(以前有,但所提及版本已废弃),正确做法是注册worldLoad事件再利用System:function handler() {
// 从 World 取得所有玩家
const players = world.getAllPlayers();
player.forEach((player) => {
// Do something...
});
}
// 注意: 所提及版本为1.17.0,将worldLoad换成worldInitialize即可(仍无world.events.tick)
// ScriptV2迁移: https://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/v2-overview?view=minecraft-bedrock-experimental
world.afterEvents.worldLoad.subscribe(() => {
// 用 System 注册回调
system.runInterval(handler);
});
EquipmentSlot是TS接口,除非你用TS写脚本再编译,否则不应当使用(TS的interface在编译成JS时会删除,在特定函数用动态类型检查代替),所以在SAPI的QuickJs语境下是import不到EquipmentSlot的。