猫史档案馆


代码岛跑酷代码

用户:撑杆僵尸撑杆僵尸查看:1 回复:1 评论:1 创建时间:2024-04-23T17:07:21


for(let x=0; x<256; x++){ for(let z=0; z<256; z++){     voxels.setVoxel(x, 8, z, 'water') }} world.onPlayerJoin(({ entity }) => {     entity.onFluidEnter(() => {//当玩家掉到水里         entity.position.copy(entity.player.spawnPoint)         entity.position.y += 2     }) }) for (const e of world.querySelectorAll('*')) {//遍历所有实体     if (e.id.startsWith('跑酷存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...         e.collides = true //开启碰撞         e.fixed = true //固定实体不被推移         e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体             if (other.isPlayer) { //另一个实体是玩家                 if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存                     other.player.directMessage('存档成功!') // 给玩家发消息                     other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标                 }             }         })     } }


回复

上一页1 页 / 共 1下一页
四喵四喵

这是整理后的代码(不含注释):

for(let x=0; x<256; x++){ 
    for(let z=0; z<256; z++){
        voxels.setVoxel(x, 8, z, 'water') 
    }
}
 world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 2     
    })
}) 
for (const e of world.querySelectorAll('*')) {
    if (e.id.startsWith('跑酷存档点')) {
        e.collides = true
        e.fixed = true 
        if (e.position !== other.player.spawnPoint) {
            other.player.directMessage('存档成功!')
            other.player.spawnPoint = e.position 
        }
    }
}

点赞1


评论