//冰块打破代码
(资料图片仅供参考)
/* 如果实体碰到冰块,冰块会被打破 */
world.onVoxelContact(({ x, y, z, voxel }) => { const voxelName = voxels.name(voxel); // 将方块id转换名称
if (voxelName === 'ice'){ // 如果方块名称是冰块
voxels.setVoxel(x, y, z, 0); // 将方块变成空气
}
})
//存档点
const saveNpcs = world.querySelectorAll('.存档点')
let saveNpc
for (saveNpc of saveNpcs) {
saveNpc.enableInteract = true; // 允许进行互动
saveNpc.interactRadius = 2; // 实体的互动范围
saveNpc.onInteract(async ({ entity, targetEntity }) => {
entity.player.spawnPoint.set(targetEntity.position.x, targetEntity.position.y + 2, targetEntity.position.z)
entity.player.directMessage('已刷新存档点,加油')
})
}
//玩家死亡
world.onVoxelContact(async ({ entity, voxel }) => {
if (voxels.name(voxel) === 'grass') {
entity.position.set(entity.player.spawnPoint.x, entity.player.spawnPoint.y, entity.player.spawnPoint.z)
}
})
X 关闭
Copyright © 2015-2022 海峡字画网版权所有 备案号:皖ICP备2022009963号-10 联系邮箱:396 029 142 @qq.com