欢迎光临散文网 会员登陆 & 注册

跑酷代码-1

2023-02-18 23:28 作者:不会音乐的屑建筑师  | 我要投稿

//冰块打破代码

/* 如果实体碰到冰块,冰块会被打破 */

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)


    }


})




跑酷代码-1的评论 (共 条)

分享到微博请遵守国家法律